From 84b6078380f895a5c3d968ad37b624494e1d8b3e Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 5 Jan 2022 08:37:31 +0000 Subject: [PATCH] CodeGen from PR 17030 in Azure/azure-rest-api-specs CosmosDB: Fix resource IDs in SqlContainer examples (#17030) --- sdk/cosmos/azure-mgmt-cosmosdb/_meta.json | 10 +- .../azure/mgmt/cosmosdb/__init__.py | 9 +- .../azure/mgmt/cosmosdb/_configuration.py | 19 +- .../cosmosdb/_cosmos_db_management_client.py | 238 +- .../azure/mgmt/cosmosdb/_metadata.json | 21 +- .../azure/mgmt/cosmosdb/_patch.py | 31 + .../azure/mgmt/cosmosdb/_vendor.py | 27 + .../azure/mgmt/cosmosdb/_version.py | 2 +- .../azure/mgmt/cosmosdb/aio/__init__.py | 5 + .../azure/mgmt/cosmosdb/aio/_configuration.py | 6 +- .../aio/_cosmos_db_management_client.py | 233 +- .../azure/mgmt/cosmosdb/aio/_patch.py | 31 + .../_cassandra_clusters_operations.py | 516 +- .../_cassandra_data_centers_operations.py | 286 +- .../_cassandra_resources_operations.py | 939 ++-- .../aio/operations/_collection_operations.py | 181 +- .../_collection_partition_operations.py | 134 +- ..._collection_partition_region_operations.py | 74 +- .../_collection_region_operations.py | 68 +- .../_database_account_region_operations.py | 62 +- .../_database_accounts_operations.py | 886 ++-- .../aio/operations/_database_operations.py | 172 +- .../_gremlin_resources_operations.py | 936 ++-- .../aio/operations/_locations_operations.py | 79 +- .../_mongo_db_resources_operations.py | 1013 ++-- .../_notebook_workspaces_operations.py | 385 +- .../cosmosdb/aio/operations/_operations.py | 45 +- .../_partition_key_range_id_operations.py | 74 +- ...artition_key_range_id_region_operations.py | 77 +- .../aio/operations/_percentile_operations.py | 65 +- .../_percentile_source_target_operations.py | 71 +- .../_percentile_target_operations.py | 68 +- ...private_endpoint_connections_operations.py | 230 +- .../_private_link_resources_operations.py | 95 +- ...restorable_database_accounts_operations.py | 137 +- ...storable_mongodb_collections_operations.py | 66 +- ...restorable_mongodb_databases_operations.py | 62 +- ...restorable_mongodb_resources_operations.py | 70 +- .../_restorable_sql_containers_operations.py | 74 +- .../_restorable_sql_databases_operations.py | 62 +- .../_restorable_sql_resources_operations.py | 70 +- .../operations/_sql_resources_operations.py | 2154 ++++---- .../operations/_table_resources_operations.py | 451 +- .../azure/mgmt/cosmosdb/models/__init__.py | 636 +-- .../_cosmos_db_management_client_enums.py | 91 +- .../azure/mgmt/cosmosdb/models/_models_py3.py | 4265 +++++++++++----- .../_cassandra_clusters_operations.py | 1049 ++-- .../_cassandra_data_centers_operations.py | 593 ++- .../_cassandra_resources_operations.py | 1873 ++++--- .../operations/_collection_operations.py | 356 +- .../_collection_partition_operations.py | 250 +- ..._collection_partition_region_operations.py | 143 +- .../_collection_region_operations.py | 140 +- .../_database_account_region_operations.py | 126 +- .../_database_accounts_operations.py | 1793 ++++--- .../operations/_database_operations.py | 335 +- .../_gremlin_resources_operations.py | 1873 ++++--- .../operations/_locations_operations.py | 166 +- .../_mongo_db_resources_operations.py | 2025 +++++--- .../_notebook_workspaces_operations.py | 783 +-- .../mgmt/cosmosdb/operations/_operations.py | 83 +- .../_partition_key_range_id_operations.py | 143 +- ...artition_key_range_id_region_operations.py | 150 +- .../operations/_percentile_operations.py | 122 +- .../_percentile_source_target_operations.py | 136 +- .../_percentile_target_operations.py | 129 +- ...private_endpoint_connections_operations.py | 462 +- .../_private_link_resources_operations.py | 195 +- ...restorable_database_accounts_operations.py | 268 +- ...storable_mongodb_collections_operations.py | 127 +- ...restorable_mongodb_databases_operations.py | 117 +- ...restorable_mongodb_resources_operations.py | 136 +- .../_restorable_sql_containers_operations.py | 145 +- .../_restorable_sql_databases_operations.py | 117 +- .../_restorable_sql_resources_operations.py | 136 +- .../operations/_sql_resources_operations.py | 4368 +++++++++++------ .../operations/_table_resources_operations.py | 909 ++-- 77 files changed, 20294 insertions(+), 14180 deletions(-) create mode 100644 sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_patch.py create mode 100644 sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py create mode 100644 sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_patch.py diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/_meta.json b/sdk/cosmos/azure-mgmt-cosmosdb/_meta.json index 0d0bba2c035c5..01e5bdacdc15e 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/_meta.json +++ b/sdk/cosmos/azure-mgmt-cosmosdb/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "a87e536b2060dfe47c4d2bbf24a7f32d67944f9c", + "commit": "8a2a6226c3ac5a882f065a66daeaf5acef334273", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/cosmos-db/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/cosmos-db/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/cosmos-db/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/__init__.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/__init__.py index 92d9f4bce48fb..12e3ce0a66c7a 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/__init__.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['CosmosDBManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` 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 +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_configuration.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_configuration.py index 0f4b69bd6638c..5ef96808c2400 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_configuration.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class CosmosDBManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(CosmosDBManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(CosmosDBManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_cosmos_db_management_client.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_cosmos_db_management_client.py index dfcc310e043dc..bf96bd8415a0d 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_cosmos_db_management_client.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_cosmos_db_management_client.py @@ -6,54 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import CosmosDBManagementClientConfiguration +from .operations import CassandraClustersOperations, CassandraDataCentersOperations, CassandraResourcesOperations, CollectionOperations, CollectionPartitionOperations, CollectionPartitionRegionOperations, CollectionRegionOperations, DatabaseAccountRegionOperations, DatabaseAccountsOperations, DatabaseOperations, GremlinResourcesOperations, LocationsOperations, MongoDBResourcesOperations, NotebookWorkspacesOperations, Operations, PartitionKeyRangeIdOperations, PartitionKeyRangeIdRegionOperations, PercentileOperations, PercentileSourceTargetOperations, PercentileTargetOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RestorableDatabaseAccountsOperations, RestorableMongodbCollectionsOperations, RestorableMongodbDatabasesOperations, RestorableMongodbResourcesOperations, RestorableSqlContainersOperations, RestorableSqlDatabasesOperations, RestorableSqlResourcesOperations, SqlResourcesOperations, TableResourcesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import CosmosDBManagementClientConfiguration -from .operations import DatabaseAccountsOperations -from .operations import Operations -from .operations import DatabaseOperations -from .operations import CollectionOperations -from .operations import CollectionRegionOperations -from .operations import DatabaseAccountRegionOperations -from .operations import PercentileSourceTargetOperations -from .operations import PercentileTargetOperations -from .operations import PercentileOperations -from .operations import CollectionPartitionRegionOperations -from .operations import CollectionPartitionOperations -from .operations import PartitionKeyRangeIdOperations -from .operations import PartitionKeyRangeIdRegionOperations -from .operations import SqlResourcesOperations -from .operations import MongoDBResourcesOperations -from .operations import TableResourcesOperations -from .operations import CassandraResourcesOperations -from .operations import GremlinResourcesOperations -from .operations import LocationsOperations -from .operations import NotebookWorkspacesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import RestorableDatabaseAccountsOperations -from .operations import RestorableSqlDatabasesOperations -from .operations import RestorableSqlContainersOperations -from .operations import RestorableSqlResourcesOperations -from .operations import RestorableMongodbDatabasesOperations -from .operations import RestorableMongodbCollectionsOperations -from .operations import RestorableMongodbResourcesOperations -from .operations import CassandraClustersOperations -from .operations import CassandraDataCentersOperations -from . import models - -class CosmosDBManagementClient(object): +class CosmosDBManagementClient: """Azure Cosmos DB Database Service Resource Provider REST API. :ivar database_accounts: DatabaseAccountsOperations operations @@ -67,21 +35,25 @@ class CosmosDBManagementClient(object): :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 + :vartype database_account_region: + azure.mgmt.cosmosdb.operations.DatabaseAccountRegionOperations :ivar percentile_source_target: PercentileSourceTargetOperations operations - :vartype percentile_source_target: azure.mgmt.cosmosdb.operations.PercentileSourceTargetOperations + :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 + :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 + :vartype partition_key_range_id_region: + azure.mgmt.cosmosdb.operations.PartitionKeyRangeIdRegionOperations :ivar sql_resources: SqlResourcesOperations operations :vartype sql_resources: azure.mgmt.cosmosdb.operations.SqlResourcesOperations :ivar mongo_db_resources: MongoDBResourcesOperations operations @@ -97,23 +69,31 @@ class CosmosDBManagementClient(object): :ivar notebook_workspaces: NotebookWorkspacesOperations operations :vartype notebook_workspaces: azure.mgmt.cosmosdb.operations.NotebookWorkspacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.cosmosdb.operations.PrivateEndpointConnectionsOperations + :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 + :vartype restorable_database_accounts: + azure.mgmt.cosmosdb.operations.RestorableDatabaseAccountsOperations :ivar restorable_sql_databases: RestorableSqlDatabasesOperations operations - :vartype restorable_sql_databases: azure.mgmt.cosmosdb.operations.RestorableSqlDatabasesOperations + :vartype restorable_sql_databases: + azure.mgmt.cosmosdb.operations.RestorableSqlDatabasesOperations :ivar restorable_sql_containers: RestorableSqlContainersOperations operations - :vartype restorable_sql_containers: azure.mgmt.cosmosdb.operations.RestorableSqlContainersOperations + :vartype restorable_sql_containers: + azure.mgmt.cosmosdb.operations.RestorableSqlContainersOperations :ivar restorable_sql_resources: RestorableSqlResourcesOperations operations - :vartype restorable_sql_resources: azure.mgmt.cosmosdb.operations.RestorableSqlResourcesOperations + :vartype restorable_sql_resources: + azure.mgmt.cosmosdb.operations.RestorableSqlResourcesOperations :ivar restorable_mongodb_databases: RestorableMongodbDatabasesOperations operations - :vartype restorable_mongodb_databases: azure.mgmt.cosmosdb.operations.RestorableMongodbDatabasesOperations + :vartype restorable_mongodb_databases: + azure.mgmt.cosmosdb.operations.RestorableMongodbDatabasesOperations :ivar restorable_mongodb_collections: RestorableMongodbCollectionsOperations operations - :vartype restorable_mongodb_collections: azure.mgmt.cosmosdb.operations.RestorableMongodbCollectionsOperations + :vartype restorable_mongodb_collections: + azure.mgmt.cosmosdb.operations.RestorableMongodbCollectionsOperations :ivar restorable_mongodb_resources: RestorableMongodbResourcesOperations operations - :vartype restorable_mongodb_resources: azure.mgmt.cosmosdb.operations.RestorableMongodbResourcesOperations + :vartype restorable_mongodb_resources: + azure.mgmt.cosmosdb.operations.RestorableMongodbResourcesOperations :ivar cassandra_clusters: CassandraClustersOperations operations :vartype cassandra_clusters: azure.mgmt.cosmosdb.operations.CassandraClustersOperations :ivar cassandra_data_centers: CassandraDataCentersOperations operations @@ -122,108 +102,84 @@ class CosmosDBManagementClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = CosmosDBManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = CosmosDBManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - 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._client, self._config, self._serialize, self._deserialize) - self.database_account_region = DatabaseAccountRegionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.percentile_source_target = PercentileSourceTargetOperations( - self._client, self._config, self._serialize, self._deserialize) - self.percentile_target = PercentileTargetOperations( - 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._client, self._config, self._serialize, self._deserialize) - self.collection_partition = CollectionPartitionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.partition_key_range_id = PartitionKeyRangeIdOperations( - self._client, self._config, self._serialize, self._deserialize) - self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations( - 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._client, self._config, self._serialize, self._deserialize) - self.table_resources = TableResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cassandra_resources = CassandraResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.gremlin_resources = GremlinResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.notebook_workspaces = NotebookWorkspacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_database_accounts = RestorableDatabaseAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_sql_databases = RestorableSqlDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_sql_containers = RestorableSqlContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_sql_resources = RestorableSqlResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_mongodb_databases = RestorableMongodbDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_mongodb_collections = RestorableMongodbCollectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_mongodb_resources = RestorableMongodbResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cassandra_clusters = CassandraClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cassandra_data_centers = CassandraDataCentersOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + 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._client, self._config, self._serialize, self._deserialize) + self.database_account_region = DatabaseAccountRegionOperations(self._client, self._config, self._serialize, self._deserialize) + self.percentile_source_target = PercentileSourceTargetOperations(self._client, self._config, self._serialize, self._deserialize) + self.percentile_target = PercentileTargetOperations(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._client, self._config, self._serialize, self._deserialize) + self.collection_partition = CollectionPartitionOperations(self._client, self._config, self._serialize, self._deserialize) + self.partition_key_range_id = PartitionKeyRangeIdOperations(self._client, self._config, self._serialize, self._deserialize) + self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations(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._client, self._config, self._serialize, self._deserialize) + self.table_resources = TableResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.cassandra_resources = CassandraResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.gremlin_resources = GremlinResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.notebook_workspaces = NotebookWorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_database_accounts = RestorableDatabaseAccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_sql_databases = RestorableSqlDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_sql_containers = RestorableSqlContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_sql_resources = RestorableSqlResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_mongodb_databases = RestorableMongodbDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_mongodb_collections = RestorableMongodbCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_mongodb_resources = RestorableMongodbResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.cassandra_clusters = CassandraClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.cassandra_data_centers = CassandraDataCentersOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_metadata.json b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_metadata.json index d319ba43be11d..a245f5a69ef7c 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_metadata.json +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_metadata.json @@ -5,13 +5,13 @@ "name": "CosmosDBManagementClient", "filename": "_cosmos_db_management_client", "description": "Azure Cosmos DB Database Service Resource Provider REST API.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CosmosDBManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CosmosDBManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CosmosDBManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CosmosDBManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "database_accounts": "DatabaseAccountsOperations", diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_patch.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# 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 \ No newline at end of file diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_version.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_version.py index b094b52a6bba2..a712687790e50 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_version.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.0.0b2" +VERSION = "0.7.0" diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/__init__.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/__init__.py index f232822d48f2d..84d58edd389cd 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/__init__.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/__init__.py @@ -8,3 +8,8 @@ from ._cosmos_db_management_client import CosmosDBManagementClient __all__ = ['CosmosDBManagementClient'] + +# `._patch.py` 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 +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_configuration.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_configuration.py index 0ca152e431252..3fa460ae3a30c 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_configuration.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(CosmosDBManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(CosmosDBManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_cosmos_db_management_client.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_cosmos_db_management_client.py index 6e5209321296c..cddd99784b970 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_cosmos_db_management_client.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_cosmos_db_management_client.py @@ -6,52 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import CosmosDBManagementClientConfiguration +from .operations import CassandraClustersOperations, CassandraDataCentersOperations, CassandraResourcesOperations, CollectionOperations, CollectionPartitionOperations, CollectionPartitionRegionOperations, CollectionRegionOperations, DatabaseAccountRegionOperations, DatabaseAccountsOperations, DatabaseOperations, GremlinResourcesOperations, LocationsOperations, MongoDBResourcesOperations, NotebookWorkspacesOperations, Operations, PartitionKeyRangeIdOperations, PartitionKeyRangeIdRegionOperations, PercentileOperations, PercentileSourceTargetOperations, PercentileTargetOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RestorableDatabaseAccountsOperations, RestorableMongodbCollectionsOperations, RestorableMongodbDatabasesOperations, RestorableMongodbResourcesOperations, RestorableSqlContainersOperations, RestorableSqlDatabasesOperations, RestorableSqlResourcesOperations, SqlResourcesOperations, TableResourcesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import CosmosDBManagementClientConfiguration -from .operations import DatabaseAccountsOperations -from .operations import Operations -from .operations import DatabaseOperations -from .operations import CollectionOperations -from .operations import CollectionRegionOperations -from .operations import DatabaseAccountRegionOperations -from .operations import PercentileSourceTargetOperations -from .operations import PercentileTargetOperations -from .operations import PercentileOperations -from .operations import CollectionPartitionRegionOperations -from .operations import CollectionPartitionOperations -from .operations import PartitionKeyRangeIdOperations -from .operations import PartitionKeyRangeIdRegionOperations -from .operations import SqlResourcesOperations -from .operations import MongoDBResourcesOperations -from .operations import TableResourcesOperations -from .operations import CassandraResourcesOperations -from .operations import GremlinResourcesOperations -from .operations import LocationsOperations -from .operations import NotebookWorkspacesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import RestorableDatabaseAccountsOperations -from .operations import RestorableSqlDatabasesOperations -from .operations import RestorableSqlContainersOperations -from .operations import RestorableSqlResourcesOperations -from .operations import RestorableMongodbDatabasesOperations -from .operations import RestorableMongodbCollectionsOperations -from .operations import RestorableMongodbResourcesOperations -from .operations import CassandraClustersOperations -from .operations import CassandraDataCentersOperations -from .. import models - - -class CosmosDBManagementClient(object): +class CosmosDBManagementClient: """Azure Cosmos DB Database Service Resource Provider REST API. :ivar database_accounts: DatabaseAccountsOperations operations @@ -65,21 +35,26 @@ class CosmosDBManagementClient(object): :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 + :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 + :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 + :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 + :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 + :vartype partition_key_range_id_region: + azure.mgmt.cosmosdb.aio.operations.PartitionKeyRangeIdRegionOperations :ivar sql_resources: SqlResourcesOperations operations :vartype sql_resources: azure.mgmt.cosmosdb.aio.operations.SqlResourcesOperations :ivar mongo_db_resources: MongoDBResourcesOperations operations @@ -95,131 +70,119 @@ class CosmosDBManagementClient(object): :ivar notebook_workspaces: NotebookWorkspacesOperations operations :vartype notebook_workspaces: azure.mgmt.cosmosdb.aio.operations.NotebookWorkspacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.cosmosdb.aio.operations.PrivateEndpointConnectionsOperations + :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 + :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 + :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 + :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 + :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 + :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 + :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 + :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 + :vartype restorable_mongodb_resources: + azure.mgmt.cosmosdb.aio.operations.RestorableMongodbResourcesOperations :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 + :vartype cassandra_data_centers: + azure.mgmt.cosmosdb.aio.operations.CassandraDataCentersOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = CosmosDBManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = CosmosDBManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + 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._client, self._config, self._serialize, self._deserialize) + self.database_account_region = DatabaseAccountRegionOperations(self._client, self._config, self._serialize, self._deserialize) + self.percentile_source_target = PercentileSourceTargetOperations(self._client, self._config, self._serialize, self._deserialize) + self.percentile_target = PercentileTargetOperations(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._client, self._config, self._serialize, self._deserialize) + self.collection_partition = CollectionPartitionOperations(self._client, self._config, self._serialize, self._deserialize) + self.partition_key_range_id = PartitionKeyRangeIdOperations(self._client, self._config, self._serialize, self._deserialize) + self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations(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._client, self._config, self._serialize, self._deserialize) + self.table_resources = TableResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.cassandra_resources = CassandraResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.gremlin_resources = GremlinResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.notebook_workspaces = NotebookWorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_database_accounts = RestorableDatabaseAccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_sql_databases = RestorableSqlDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_sql_containers = RestorableSqlContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_sql_resources = RestorableSqlResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_mongodb_databases = RestorableMongodbDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_mongodb_collections = RestorableMongodbCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_mongodb_resources = RestorableMongodbResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.cassandra_clusters = CassandraClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.cassandra_data_centers = CassandraDataCentersOperations(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._client, self._config, self._serialize, self._deserialize) - self.database_account_region = DatabaseAccountRegionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.percentile_source_target = PercentileSourceTargetOperations( - self._client, self._config, self._serialize, self._deserialize) - self.percentile_target = PercentileTargetOperations( - 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._client, self._config, self._serialize, self._deserialize) - self.collection_partition = CollectionPartitionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.partition_key_range_id = PartitionKeyRangeIdOperations( - self._client, self._config, self._serialize, self._deserialize) - self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations( - 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._client, self._config, self._serialize, self._deserialize) - self.table_resources = TableResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cassandra_resources = CassandraResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.gremlin_resources = GremlinResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.notebook_workspaces = NotebookWorkspacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_database_accounts = RestorableDatabaseAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_sql_databases = RestorableSqlDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_sql_containers = RestorableSqlContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_sql_resources = RestorableSqlResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_mongodb_databases = RestorableMongodbDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_mongodb_collections = RestorableMongodbCollectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.restorable_mongodb_resources = RestorableMongodbResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cassandra_clusters = CassandraClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cassandra_data_centers = CassandraDataCentersOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_patch.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# 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 \ No newline at end of file diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_clusters_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_clusters_operations.py index b5d2b9f1208f0..fb45e7dd53de8 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_clusters_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_clusters_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._cassandra_clusters_operations import build_create_update_request_initial, build_deallocate_request_initial, build_delete_request_initial, build_get_request, build_invoke_command_request_initial, build_list_by_resource_group_request, build_list_by_subscription_request, build_start_request_initial, build_status_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -59,34 +65,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListClusters', pipeline_response) + deserialized = self._deserialize("ListClusters", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,11 +105,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -128,35 +131,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListClusters', pipeline_response) + deserialized = self._deserialize("ListClusters", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,11 +173,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,27 +202,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +226,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -248,27 +241,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -281,6 +264,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -295,15 +280,17 @@ async def begin_delete( :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -317,21 +304,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -343,6 +323,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore async def _create_update_initial( @@ -357,32 +338,22 @@ async def _create_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ClusterResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self._create_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ClusterResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -400,8 +371,11 @@ async def _create_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore + + @distributed_trace_async async def begin_create_update( self, resource_group_name: str, @@ -420,15 +394,19 @@ async def begin_create_update( :type body: ~azure.mgmt.cosmosdb.models.ClusterResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ClusterResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterResource or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -440,27 +418,21 @@ async def begin_create_update( resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ClusterResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -472,6 +444,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore async def _update_initial( @@ -486,32 +459,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'ClusterResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ClusterResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -529,8 +492,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -548,15 +514,19 @@ async def begin_update( :type body: ~azure.mgmt.cosmosdb.models.ClusterResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ClusterResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterResource or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -568,27 +538,21 @@ async def begin_update( resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ClusterResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -600,6 +564,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore async def _invoke_command_initial( @@ -614,32 +579,22 @@ async def _invoke_command_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._invoke_command_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'CommandPostBody') + + request = build_invoke_command_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self._invoke_command_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'CommandPostBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -653,8 +608,11 @@ async def _invoke_command_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _invoke_command_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand'} # type: ignore + + @distributed_trace_async async def begin_invoke_command( self, resource_group_name: str, @@ -672,15 +630,19 @@ async def begin_invoke_command( :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either CommandOutput or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CommandOutput"] lro_delay = kwargs.pop( 'polling_interval', @@ -692,27 +654,21 @@ async def begin_invoke_command( resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CommandOutput', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -724,6 +680,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_invoke_command.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand'} # type: ignore async def _deallocate_initial( @@ -737,27 +694,17 @@ async def _deallocate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._deallocate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_deallocate_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self._deallocate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -770,6 +717,8 @@ async def _deallocate_initial( _deallocate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate'} # type: ignore + + @distributed_trace_async async def begin_deallocate( self, resource_group_name: str, @@ -786,15 +735,17 @@ async def begin_deallocate( :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -808,21 +759,14 @@ async def begin_deallocate( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -834,6 +778,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_deallocate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate'} # type: ignore async def _start_initial( @@ -847,27 +792,17 @@ async def _start_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -880,6 +815,8 @@ async def _start_initial( _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start'} # type: ignore + + @distributed_trace_async async def begin_start( self, resource_group_name: str, @@ -896,15 +833,17 @@ async def begin_start( :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -918,21 +857,14 @@ async def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -944,8 +876,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start'} # type: ignore + @distributed_trace_async async def status( self, resource_group_name: str, @@ -968,27 +902,17 @@ async def status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_status_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self.status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1002,4 +926,6 @@ async def status( return cls(pipeline_response, deserialized, {}) return deserialized + status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/status'} # type: ignore + diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_data_centers_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_data_centers_operations.py index dbf2c167b009e..c4cb7d83584a4 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_data_centers_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_data_centers_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._cassandra_data_centers_operations import build_create_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -65,36 +71,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListDataCenters', pipeline_response) + deserialized = self._deserialize("ListDataCenters", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,11 +115,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -142,28 +147,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + data_center_name=data_center_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,8 +172,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -191,28 +188,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + data_center_name=data_center_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -225,6 +212,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -242,15 +231,17 @@ async def begin_delete( :type data_center_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -265,22 +256,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -292,6 +275,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore async def _create_update_initial( @@ -307,33 +291,23 @@ async def _create_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'DataCenterResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + data_center_name=data_center_name, + content_type=content_type, + json=_json, + template_url=self._create_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'DataCenterResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -351,8 +325,11 @@ async def _create_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore + + @distributed_trace_async async def begin_create_update( self, resource_group_name: str, @@ -374,15 +351,19 @@ async def begin_create_update( :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DataCenterResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataCenterResource or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCenterResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -395,28 +376,21 @@ async def begin_create_update( cluster_name=cluster_name, data_center_name=data_center_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DataCenterResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -428,6 +402,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore async def _update_initial( @@ -443,33 +418,23 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'DataCenterResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + data_center_name=data_center_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'DataCenterResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -487,8 +452,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -509,15 +477,19 @@ async def begin_update( :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DataCenterResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataCenterResource or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCenterResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -530,28 +502,21 @@ async def begin_update( cluster_name=cluster_name, data_center_name=data_center_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DataCenterResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -563,4 +528,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_resources_operations.py index e6afae1253682..1c76a816b8d45 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_cassandra_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._cassandra_resources_operations import build_create_update_cassandra_keyspace_request_initial, build_create_update_cassandra_table_request_initial, build_delete_cassandra_keyspace_request_initial, build_delete_cassandra_table_request_initial, build_get_cassandra_keyspace_request, build_get_cassandra_keyspace_throughput_request, build_get_cassandra_table_request, build_get_cassandra_table_throughput_request, build_list_cassandra_keyspaces_request, build_list_cassandra_tables_request, build_migrate_cassandra_keyspace_to_autoscale_request_initial, build_migrate_cassandra_keyspace_to_manual_throughput_request_initial, build_migrate_cassandra_table_to_autoscale_request_initial, build_migrate_cassandra_table_to_manual_throughput_request_initial, build_update_cassandra_keyspace_throughput_request_initial, build_update_cassandra_table_throughput_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_cassandra_keyspaces( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list_cassandra_keyspaces( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CassandraKeyspaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceListResult] + :return: An iterator like instance of either CassandraKeyspaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CassandraKeyspaceListResult"] @@ -65,36 +73,33 @@ def list_cassandra_keyspaces( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_cassandra_keyspaces.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_cassandra_keyspaces_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_cassandra_keyspaces.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_cassandra_keyspaces_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("CassandraKeyspaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,11 +117,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_cassandra_keyspaces.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces'} # type: ignore + @distributed_trace_async async def get_cassandra_keyspace( self, resource_group_name: str, @@ -143,28 +150,18 @@ async def get_cassandra_keyspace( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_cassandra_keyspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_cassandra_keyspace_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self.get_cassandra_keyspace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -178,8 +175,10 @@ async def get_cassandra_keyspace( return cls(pipeline_response, deserialized, {}) return deserialized + get_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore + async def _create_update_cassandra_keyspace_initial( self, resource_group_name: str, @@ -193,33 +192,23 @@ async def _create_update_cassandra_keyspace_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_cassandra_keyspace_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_cassandra_keyspace_parameters, 'CassandraKeyspaceCreateUpdateParameters') + + request = build_create_update_cassandra_keyspace_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + content_type=content_type, + json=_json, + template_url=self._create_update_cassandra_keyspace_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_cassandra_keyspace_parameters, 'CassandraKeyspaceCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def _create_update_cassandra_keyspace_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_cassandra_keyspace_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_cassandra_keyspace( self, resource_group_name: str, @@ -255,18 +247,24 @@ async def begin_create_update_cassandra_keyspace( :type keyspace_name: str :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current Cassandra keyspace. - :type create_update_cassandra_keyspace_parameters: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters + :type create_update_cassandra_keyspace_parameters: + ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either CassandraKeyspaceGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CassandraKeyspaceGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CassandraKeyspaceGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +277,21 @@ async def begin_create_update_cassandra_keyspace( account_name=account_name, keyspace_name=keyspace_name, create_update_cassandra_keyspace_parameters=create_update_cassandra_keyspace_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CassandraKeyspaceGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -312,6 +303,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore async def _delete_cassandra_keyspace_initial( @@ -326,26 +318,18 @@ async def _delete_cassandra_keyspace_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_cassandra_keyspace_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_cassandra_keyspace_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self._delete_cassandra_keyspace_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -358,6 +342,8 @@ async def _delete_cassandra_keyspace_initial( _delete_cassandra_keyspace_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore + + @distributed_trace_async async def begin_delete_cassandra_keyspace( self, resource_group_name: str, @@ -375,15 +361,17 @@ async def begin_delete_cassandra_keyspace( :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -398,22 +386,14 @@ async def begin_delete_cassandra_keyspace( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -425,8 +405,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore + @distributed_trace_async async def get_cassandra_keyspace_throughput( self, resource_group_name: str, @@ -453,28 +435,18 @@ async def get_cassandra_keyspace_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_cassandra_keyspace_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_cassandra_keyspace_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self.get_cassandra_keyspace_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -488,8 +460,10 @@ async def get_cassandra_keyspace_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_cassandra_keyspace_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default'} # type: ignore + async def _update_cassandra_keyspace_throughput_initial( self, resource_group_name: str, @@ -503,33 +477,23 @@ async def _update_cassandra_keyspace_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_cassandra_keyspace_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_cassandra_keyspace_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + content_type=content_type, + json=_json, + template_url=self._update_cassandra_keyspace_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -545,8 +509,11 @@ async def _update_cassandra_keyspace_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_cassandra_keyspace_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_cassandra_keyspace_throughput( self, resource_group_name: str, @@ -565,18 +532,24 @@ async def begin_update_cassandra_keyspace_throughput( :type keyspace_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current Cassandra Keyspace. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -589,28 +562,21 @@ async def begin_update_cassandra_keyspace_throughput( account_name=account_name, keyspace_name=keyspace_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -622,6 +588,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_cassandra_keyspace_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default'} # type: ignore async def _migrate_cassandra_keyspace_to_autoscale_initial( @@ -636,28 +603,18 @@ async def _migrate_cassandra_keyspace_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_cassandra_keyspace_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_cassandra_keyspace_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self._migrate_cassandra_keyspace_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -673,8 +630,11 @@ async def _migrate_cassandra_keyspace_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_cassandra_keyspace_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_cassandra_keyspace_to_autoscale( self, resource_group_name: str, @@ -692,15 +652,19 @@ async def begin_migrate_cassandra_keyspace_to_autoscale( :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -715,25 +679,17 @@ async def begin_migrate_cassandra_keyspace_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -745,6 +701,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_cassandra_keyspace_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_cassandra_keyspace_to_manual_throughput_initial( @@ -759,28 +716,18 @@ async def _migrate_cassandra_keyspace_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_cassandra_keyspace_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_cassandra_keyspace_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self._migrate_cassandra_keyspace_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -796,8 +743,11 @@ async def _migrate_cassandra_keyspace_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_cassandra_keyspace_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_cassandra_keyspace_to_manual_throughput( self, resource_group_name: str, @@ -815,15 +765,19 @@ async def begin_migrate_cassandra_keyspace_to_manual_throughput( :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -838,25 +792,17 @@ async def begin_migrate_cassandra_keyspace_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -868,8 +814,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_cassandra_keyspace_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_cassandra_tables( self, resource_group_name: str, @@ -886,8 +834,10 @@ def list_cassandra_tables( :param keyspace_name: Cosmos DB keyspace name. :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CassandraTableListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableListResult] + :return: An iterator like instance of either CassandraTableListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CassandraTableListResult"] @@ -895,37 +845,35 @@ def list_cassandra_tables( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_cassandra_tables.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_cassandra_tables_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self.list_cassandra_tables.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_cassandra_tables_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CassandraTableListResult', pipeline_response) + deserialized = self._deserialize("CassandraTableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -943,11 +891,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_cassandra_tables.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables'} # type: ignore + @distributed_trace_async async def get_cassandra_table( self, resource_group_name: str, @@ -976,29 +926,19 @@ async def get_cassandra_table( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_cassandra_table.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_cassandra_table_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self.get_cassandra_table.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1012,8 +952,10 @@ async def get_cassandra_table( return cls(pipeline_response, deserialized, {}) return deserialized + get_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore + async def _create_update_cassandra_table_initial( self, resource_group_name: str, @@ -1028,34 +970,24 @@ async def _create_update_cassandra_table_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_cassandra_table_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_cassandra_table_parameters, 'CassandraTableCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_cassandra_table_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + content_type=content_type, + json=_json, + template_url=self._create_update_cassandra_table_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_cassandra_table_parameters, 'CassandraTableCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1071,8 +1003,11 @@ async def _create_update_cassandra_table_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_cassandra_table_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_cassandra_table( self, resource_group_name: str, @@ -1094,18 +1029,24 @@ async def begin_create_update_cassandra_table( :type table_name: str :param create_update_cassandra_table_parameters: The parameters to provide for the current Cassandra Table. - :type create_update_cassandra_table_parameters: ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters + :type create_update_cassandra_table_parameters: + ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either CassandraTableGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CassandraTableGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CassandraTableGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1119,29 +1060,21 @@ async def begin_create_update_cassandra_table( keyspace_name=keyspace_name, table_name=table_name, create_update_cassandra_table_parameters=create_update_cassandra_table_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CassandraTableGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1153,6 +1086,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore async def _delete_cassandra_table_initial( @@ -1168,27 +1102,19 @@ async def _delete_cassandra_table_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_cassandra_table_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_cassandra_table_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self._delete_cassandra_table_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1201,6 +1127,8 @@ async def _delete_cassandra_table_initial( _delete_cassandra_table_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore + + @distributed_trace_async async def begin_delete_cassandra_table( self, resource_group_name: str, @@ -1221,15 +1149,17 @@ async def begin_delete_cassandra_table( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1245,23 +1175,14 @@ async def begin_delete_cassandra_table( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1273,8 +1194,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore + @distributed_trace_async async def get_cassandra_table_throughput( self, resource_group_name: str, @@ -1304,29 +1227,19 @@ async def get_cassandra_table_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_cassandra_table_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_cassandra_table_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self.get_cassandra_table_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1340,8 +1253,10 @@ async def get_cassandra_table_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_cassandra_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default'} # type: ignore + async def _update_cassandra_table_throughput_initial( self, resource_group_name: str, @@ -1356,34 +1271,24 @@ async def _update_cassandra_table_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_cassandra_table_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_cassandra_table_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + content_type=content_type, + json=_json, + template_url=self._update_cassandra_table_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1399,8 +1304,11 @@ async def _update_cassandra_table_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_cassandra_table_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_cassandra_table_throughput( self, resource_group_name: str, @@ -1422,18 +1330,24 @@ async def begin_update_cassandra_table_throughput( :type table_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current Cassandra table. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1447,29 +1361,21 @@ async def begin_update_cassandra_table_throughput( keyspace_name=keyspace_name, table_name=table_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1481,6 +1387,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_cassandra_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default'} # type: ignore async def _migrate_cassandra_table_to_autoscale_initial( @@ -1496,29 +1403,19 @@ async def _migrate_cassandra_table_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_cassandra_table_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_cassandra_table_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self._migrate_cassandra_table_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1534,8 +1431,11 @@ async def _migrate_cassandra_table_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_cassandra_table_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_cassandra_table_to_autoscale( self, resource_group_name: str, @@ -1556,15 +1456,19 @@ async def begin_migrate_cassandra_table_to_autoscale( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1580,26 +1484,17 @@ async def begin_migrate_cassandra_table_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1611,6 +1506,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_cassandra_table_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_cassandra_table_to_manual_throughput_initial( @@ -1626,29 +1522,19 @@ async def _migrate_cassandra_table_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_cassandra_table_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_cassandra_table_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self._migrate_cassandra_table_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1664,8 +1550,11 @@ async def _migrate_cassandra_table_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_cassandra_table_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_cassandra_table_to_manual_throughput( self, resource_group_name: str, @@ -1686,15 +1575,19 @@ async def begin_migrate_cassandra_table_to_manual_throughput( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1710,26 +1603,17 @@ async def begin_migrate_cassandra_table_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1741,4 +1625,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_cassandra_table_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_operations.py index e6e996a43f9f8..0587d4f84611e 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._collection_operations import build_list_metric_definitions_request, build_list_metrics_request, build_list_usages_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -75,39 +81,39 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,11 +131,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics'} # type: ignore + @distributed_trace def list_usages( self, resource_group_name: str, @@ -162,40 +170,39 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UsagesResult', pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -213,11 +220,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages'} # type: ignore + @distributed_trace def list_metric_definitions( self, resource_group_name: str, @@ -237,8 +246,10 @@ def list_metric_definitions( :param collection_rid: Cosmos DB collection rid. :type collection_rid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] + :return: An iterator like instance of either MetricDefinitionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionsListResult"] @@ -246,38 +257,37 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -295,6 +305,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_partition_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_partition_operations.py index b459e55f2ff41..6625c68020f53 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_partition_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_partition_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._collection_partition_operations import build_list_metrics_request, build_list_usages_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -66,8 +72,10 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionMetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] + :return: An iterator like instance of either PartitionMetricListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PartitionMetricListResult"] @@ -75,39 +83,39 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionMetricListResult', pipeline_response) + deserialized = self._deserialize("PartitionMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,11 +133,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics'} # type: ignore + @distributed_trace def list_usages( self, resource_group_name: str, @@ -153,8 +163,10 @@ def list_usages( supported parameter is name.value (name of the metric, can have an or of multiple names). :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionUsagesResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionUsagesResult] + :return: An iterator like instance of either PartitionUsagesResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PartitionUsagesResult"] @@ -162,40 +174,39 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionUsagesResult', pipeline_response) + deserialized = self._deserialize("PartitionUsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -213,6 +224,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_partition_region_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_partition_region_operations.py index 979d472ba9964..3e00d229454a5 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_partition_region_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_partition_region_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._collection_partition_region_operations import build_list_metrics_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -69,8 +75,10 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionMetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] + :return: An iterator like instance of either PartitionMetricListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PartitionMetricListResult"] @@ -78,40 +86,41 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'region': self._serialize.url("region", region, 'str'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionMetricListResult', pipeline_response) + deserialized = self._deserialize("PartitionMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,6 +138,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_region_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_region_operations.py index 5b3fa9f1cf969..2ae679ecd24d8 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_region_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_collection_region_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._collection_region_operations import build_list_metrics_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -78,40 +84,41 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'region': self._serialize.url("region", region, 'str'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,6 +136,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_account_region_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_account_region_operations.py index 3f198398c2957..eabc0b676ba0c 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_account_region_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_account_region_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_account_region_operations import build_list_metrics_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -71,38 +77,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'region': self._serialize.url("region", region, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,6 +125,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_accounts_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_accounts_operations.py index 5b2628c7b5da6..f790fcfbf59db 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_accounts_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_accounts_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_accounts_operations import build_check_name_exists_request, build_create_or_update_request_initial, build_delete_request_initial, build_failover_priority_change_request_initial, build_get_read_only_keys_request, build_get_request, build_list_by_resource_group_request, build_list_connection_strings_request, build_list_keys_request, build_list_metric_definitions_request, build_list_metrics_request, build_list_read_only_keys_request, build_list_request, build_list_usages_request, build_offline_region_request_initial, build_online_region_request_initial, build_regenerate_key_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -65,27 +71,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,8 +95,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore + async def _update_initial( self, resource_group_name: str, @@ -113,32 +111,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_parameters, 'DatabaseAccountUpdateParameters') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_parameters, 'DatabaseAccountUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -152,8 +140,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -171,15 +162,20 @@ async def begin_update( :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DatabaseAccountGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DatabaseAccountGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseAccountGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -191,27 +187,21 @@ async def begin_update( resource_group_name=resource_group_name, account_name=account_name, update_parameters=update_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -223,6 +213,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore async def _create_or_update_initial( @@ -237,32 +228,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_parameters, 'DatabaseAccountCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_parameters, 'DatabaseAccountCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -276,8 +257,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -293,18 +277,24 @@ async def begin_create_or_update( :param account_name: Cosmos DB database account name. :type account_name: str :param create_update_parameters: The parameters to provide for the current database account. - :type create_update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DatabaseAccountGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DatabaseAccountGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseAccountGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -316,27 +306,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, account_name=account_name, create_update_parameters=create_update_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -348,6 +332,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore async def _delete_initial( @@ -361,25 +346,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -392,6 +369,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -406,15 +385,17 @@ async def begin_delete( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -428,21 +409,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -454,6 +428,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore async def _failover_priority_change_initial( @@ -468,30 +443,22 @@ async def _failover_priority_change_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._failover_priority_change_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(failover_parameters, 'FailoverPolicies') + + request = build_failover_priority_change_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._failover_priority_change_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_parameters, 'FailoverPolicies') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -504,6 +471,8 @@ async def _failover_priority_change_initial( _failover_priority_change_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange'} # type: ignore + + @distributed_trace_async async def begin_failover_priority_change( self, resource_group_name: str, @@ -524,15 +493,18 @@ async def begin_failover_priority_change( :type failover_parameters: ~azure.mgmt.cosmosdb.models.FailoverPolicies :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -544,24 +516,18 @@ async def begin_failover_priority_change( resource_group_name=resource_group_name, account_name=account_name, failover_parameters=failover_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -573,8 +539,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover_priority_change.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -582,8 +550,10 @@ def list( """Lists all the Azure Cosmos DB database accounts available under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseAccountsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] + :return: An iterator like instance of either DatabaseAccountsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseAccountsListResult"] @@ -591,34 +561,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("DatabaseAccountsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -636,11 +601,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -651,8 +618,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseAccountsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] + :return: An iterator like instance of either DatabaseAccountsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseAccountsListResult"] @@ -660,35 +629,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("DatabaseAccountsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -706,11 +671,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts'} # type: ignore + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -733,27 +700,17 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -767,8 +724,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys'} # type: ignore + + @distributed_trace_async async def list_connection_strings( self, resource_group_name: str, @@ -791,27 +751,17 @@ async def list_connection_strings( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.list_connection_strings.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_connection_strings_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_connection_strings.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -825,8 +775,10 @@ async def list_connection_strings( return cls(pipeline_response, deserialized, {}) return deserialized + list_connection_strings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings'} # type: ignore + async def _offline_region_initial( self, resource_group_name: str, @@ -839,45 +791,36 @@ async def _offline_region_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._offline_region_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(region_parameter_for_offline, 'RegionForOnlineOffline') + + request = build_offline_region_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._offline_region_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(region_parameter_for_offline, 'RegionForOnlineOffline') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _offline_region_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion'} # type: ignore + + @distributed_trace_async async def begin_offline_region( self, resource_group_name: str, @@ -895,15 +838,18 @@ async def begin_offline_region( :type region_parameter_for_offline: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -915,24 +861,18 @@ async def begin_offline_region( resource_group_name=resource_group_name, account_name=account_name, region_parameter_for_offline=region_parameter_for_offline, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -944,6 +884,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_offline_region.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion'} # type: ignore async def _online_region_initial( @@ -958,45 +899,36 @@ async def _online_region_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._online_region_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(region_parameter_for_online, 'RegionForOnlineOffline') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_online_region_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._online_region_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(region_parameter_for_online, 'RegionForOnlineOffline') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _online_region_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion'} # type: ignore + + @distributed_trace_async async def begin_online_region( self, resource_group_name: str, @@ -1014,15 +946,18 @@ async def begin_online_region( :type region_parameter_for_online: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1034,24 +969,18 @@ async def begin_online_region( resource_group_name=resource_group_name, account_name=account_name, region_parameter_for_online=region_parameter_for_online, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1063,8 +992,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_online_region.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion'} # type: ignore + @distributed_trace_async async def get_read_only_keys( self, resource_group_name: str, @@ -1087,27 +1018,17 @@ async def get_read_only_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_read_only_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_read_only_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get_read_only_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1121,8 +1042,11 @@ async def get_read_only_keys( return cls(pipeline_response, deserialized, {}) return deserialized + get_read_only_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys'} # type: ignore + + @distributed_trace_async async def list_read_only_keys( self, resource_group_name: str, @@ -1145,27 +1069,17 @@ async def list_read_only_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.list_read_only_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_read_only_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_read_only_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1179,8 +1093,10 @@ async def list_read_only_keys( return cls(pipeline_response, deserialized, {}) return deserialized + list_read_only_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys'} # type: ignore + async def _regenerate_key_initial( self, resource_group_name: str, @@ -1193,30 +1109,22 @@ async def _regenerate_key_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._regenerate_key_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(key_to_regenerate, 'DatabaseAccountRegenerateKeyParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_regenerate_key_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._regenerate_key_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(key_to_regenerate, 'DatabaseAccountRegenerateKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1229,6 +1137,8 @@ async def _regenerate_key_initial( _regenerate_key_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey'} # type: ignore + + @distributed_trace_async async def begin_regenerate_key( self, resource_group_name: str, @@ -1246,15 +1156,18 @@ async def begin_regenerate_key( :type key_to_regenerate: ~azure.mgmt.cosmosdb.models.DatabaseAccountRegenerateKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1266,24 +1179,18 @@ async def begin_regenerate_key( resource_group_name=resource_group_name, account_name=account_name, key_to_regenerate=key_to_regenerate, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1295,8 +1202,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey'} # type: ignore + @distributed_trace_async async def check_name_exists( self, account_name: str, @@ -1318,23 +1227,15 @@ async def check_name_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self.check_name_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_name_exists_request( + account_name=account_name, + template_url=self.check_name_exists.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1344,10 +1245,12 @@ async def check_name_exists( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_name_exists.metadata = {'url': '/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}'} # type: ignore + + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -1375,37 +1278,35 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1423,11 +1324,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics'} # type: ignore + @distributed_trace def list_usages( self, resource_group_name: str, @@ -1454,38 +1357,35 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UsagesResult', pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1503,11 +1403,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages'} # type: ignore + @distributed_trace def list_metric_definitions( self, resource_group_name: str, @@ -1521,8 +1423,10 @@ def list_metric_definitions( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] + :return: An iterator like instance of either MetricDefinitionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionsListResult"] @@ -1530,36 +1434,33 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1577,6 +1478,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_operations.py index a4ac9707bc681..9d040c0507a4e 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_database_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._database_operations import build_list_metric_definitions_request, build_list_metrics_request, build_list_usages_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -72,38 +78,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,11 +126,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics'} # type: ignore + @distributed_trace def list_usages( self, resource_group_name: str, @@ -155,39 +162,37 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UsagesResult', pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -205,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages'} # type: ignore + @distributed_trace def list_metric_definitions( self, resource_group_name: str, @@ -226,8 +233,10 @@ def list_metric_definitions( :param database_rid: Cosmos DB database rid. :type database_rid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] + :return: An iterator like instance of either MetricDefinitionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionsListResult"] @@ -235,37 +244,35 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -283,6 +290,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_gremlin_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_gremlin_resources_operations.py index 0bc7fffca75f3..a2f8d531aa82f 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_gremlin_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_gremlin_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._gremlin_resources_operations import build_create_update_gremlin_database_request_initial, build_create_update_gremlin_graph_request_initial, build_delete_gremlin_database_request_initial, build_delete_gremlin_graph_request_initial, build_get_gremlin_database_request, build_get_gremlin_database_throughput_request, build_get_gremlin_graph_request, build_get_gremlin_graph_throughput_request, build_list_gremlin_databases_request, build_list_gremlin_graphs_request, build_migrate_gremlin_database_to_autoscale_request_initial, build_migrate_gremlin_database_to_manual_throughput_request_initial, build_migrate_gremlin_graph_to_autoscale_request_initial, build_migrate_gremlin_graph_to_manual_throughput_request_initial, build_update_gremlin_database_throughput_request_initial, build_update_gremlin_graph_throughput_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_gremlin_databases( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list_gremlin_databases( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GremlinDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinDatabaseListResult] + :return: An iterator like instance of either GremlinDatabaseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GremlinDatabaseListResult"] @@ -65,36 +73,33 @@ def list_gremlin_databases( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_gremlin_databases.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_gremlin_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_gremlin_databases.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_gremlin_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GremlinDatabaseListResult', pipeline_response) + deserialized = self._deserialize("GremlinDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,11 +117,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_gremlin_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases'} # type: ignore + @distributed_trace_async async def get_gremlin_database( self, resource_group_name: str, @@ -143,28 +150,18 @@ async def get_gremlin_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_gremlin_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_gremlin_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_gremlin_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -178,8 +175,10 @@ async def get_gremlin_database( return cls(pipeline_response, deserialized, {}) return deserialized + get_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore + async def _create_update_gremlin_database_initial( self, resource_group_name: str, @@ -193,33 +192,23 @@ async def _create_update_gremlin_database_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_gremlin_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_gremlin_database_parameters, 'GremlinDatabaseCreateUpdateParameters') + + request = build_create_update_gremlin_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._create_update_gremlin_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_gremlin_database_parameters, 'GremlinDatabaseCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def _create_update_gremlin_database_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_gremlin_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_gremlin_database( self, resource_group_name: str, @@ -255,18 +247,24 @@ async def begin_create_update_gremlin_database( :type database_name: str :param create_update_gremlin_database_parameters: The parameters to provide for the current Gremlin database. - :type create_update_gremlin_database_parameters: ~azure.mgmt.cosmosdb.models.GremlinDatabaseCreateUpdateParameters + :type create_update_gremlin_database_parameters: + ~azure.mgmt.cosmosdb.models.GremlinDatabaseCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either GremlinDatabaseGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GremlinDatabaseGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GremlinDatabaseGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +277,21 @@ async def begin_create_update_gremlin_database( account_name=account_name, database_name=database_name, create_update_gremlin_database_parameters=create_update_gremlin_database_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GremlinDatabaseGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -312,6 +303,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore async def _delete_gremlin_database_initial( @@ -326,26 +318,18 @@ async def _delete_gremlin_database_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_gremlin_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_gremlin_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._delete_gremlin_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -358,6 +342,8 @@ async def _delete_gremlin_database_initial( _delete_gremlin_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_delete_gremlin_database( self, resource_group_name: str, @@ -375,15 +361,17 @@ async def begin_delete_gremlin_database( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -398,22 +386,14 @@ async def begin_delete_gremlin_database( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -425,8 +405,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore + @distributed_trace_async async def get_gremlin_database_throughput( self, resource_group_name: str, @@ -453,28 +435,18 @@ async def get_gremlin_database_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_gremlin_database_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_gremlin_database_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_gremlin_database_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -488,8 +460,10 @@ async def get_gremlin_database_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_gremlin_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default'} # type: ignore + async def _update_gremlin_database_throughput_initial( self, resource_group_name: str, @@ -503,33 +477,23 @@ async def _update_gremlin_database_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_gremlin_database_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_gremlin_database_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._update_gremlin_database_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -545,8 +509,11 @@ async def _update_gremlin_database_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_gremlin_database_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_gremlin_database_throughput( self, resource_group_name: str, @@ -565,18 +532,24 @@ async def begin_update_gremlin_database_throughput( :type database_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current Gremlin database. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -589,28 +562,21 @@ async def begin_update_gremlin_database_throughput( account_name=account_name, database_name=database_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -622,6 +588,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_gremlin_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default'} # type: ignore async def _migrate_gremlin_database_to_autoscale_initial( @@ -636,28 +603,18 @@ async def _migrate_gremlin_database_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_gremlin_database_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_gremlin_database_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_gremlin_database_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -673,8 +630,11 @@ async def _migrate_gremlin_database_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_gremlin_database_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_gremlin_database_to_autoscale( self, resource_group_name: str, @@ -692,15 +652,19 @@ async def begin_migrate_gremlin_database_to_autoscale( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -715,25 +679,17 @@ async def begin_migrate_gremlin_database_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -745,6 +701,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_gremlin_database_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_gremlin_database_to_manual_throughput_initial( @@ -759,28 +716,18 @@ async def _migrate_gremlin_database_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_gremlin_database_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_gremlin_database_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_gremlin_database_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -796,8 +743,11 @@ async def _migrate_gremlin_database_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_gremlin_database_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_gremlin_database_to_manual_throughput( self, resource_group_name: str, @@ -815,15 +765,19 @@ async def begin_migrate_gremlin_database_to_manual_throughput( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -838,25 +792,17 @@ async def begin_migrate_gremlin_database_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -868,8 +814,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_gremlin_database_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_gremlin_graphs( self, resource_group_name: str, @@ -886,8 +834,10 @@ def list_gremlin_graphs( :param database_name: Cosmos DB database name. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GremlinGraphListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphListResult] + :return: An iterator like instance of either GremlinGraphListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GremlinGraphListResult"] @@ -895,37 +845,35 @@ def list_gremlin_graphs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_gremlin_graphs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_gremlin_graphs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.list_gremlin_graphs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_gremlin_graphs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("GremlinGraphListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -943,11 +891,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_gremlin_graphs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs'} # type: ignore + @distributed_trace_async async def get_gremlin_graph( self, resource_group_name: str, @@ -976,29 +926,19 @@ async def get_gremlin_graph( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_gremlin_graph.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_gremlin_graph_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self.get_gremlin_graph.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1012,8 +952,10 @@ async def get_gremlin_graph( return cls(pipeline_response, deserialized, {}) return deserialized + get_gremlin_graph.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore + async def _create_update_gremlin_graph_initial( self, resource_group_name: str, @@ -1028,34 +970,24 @@ async def _create_update_gremlin_graph_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_gremlin_graph_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_gremlin_graph_parameters, 'GremlinGraphCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_gremlin_graph_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + content_type=content_type, + json=_json, + template_url=self._create_update_gremlin_graph_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_gremlin_graph_parameters, 'GremlinGraphCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1071,8 +1003,11 @@ async def _create_update_gremlin_graph_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_gremlin_graph_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_gremlin_graph( self, resource_group_name: str, @@ -1094,18 +1029,23 @@ async def begin_create_update_gremlin_graph( :type graph_name: str :param create_update_gremlin_graph_parameters: The parameters to provide for the current Gremlin graph. - :type create_update_gremlin_graph_parameters: ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters + :type create_update_gremlin_graph_parameters: + ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either GremlinGraphGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GremlinGraphGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1119,29 +1059,21 @@ async def begin_create_update_gremlin_graph( database_name=database_name, graph_name=graph_name, create_update_gremlin_graph_parameters=create_update_gremlin_graph_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GremlinGraphGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1153,6 +1085,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_gremlin_graph.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore async def _delete_gremlin_graph_initial( @@ -1168,27 +1101,19 @@ async def _delete_gremlin_graph_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_gremlin_graph_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_gremlin_graph_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self._delete_gremlin_graph_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1201,6 +1126,8 @@ async def _delete_gremlin_graph_initial( _delete_gremlin_graph_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore + + @distributed_trace_async async def begin_delete_gremlin_graph( self, resource_group_name: str, @@ -1221,15 +1148,17 @@ async def begin_delete_gremlin_graph( :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1245,23 +1174,14 @@ async def begin_delete_gremlin_graph( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1273,8 +1193,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_gremlin_graph.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore + @distributed_trace_async async def get_gremlin_graph_throughput( self, resource_group_name: str, @@ -1304,29 +1226,19 @@ async def get_gremlin_graph_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_gremlin_graph_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_gremlin_graph_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self.get_gremlin_graph_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1340,8 +1252,10 @@ async def get_gremlin_graph_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_gremlin_graph_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default'} # type: ignore + async def _update_gremlin_graph_throughput_initial( self, resource_group_name: str, @@ -1356,34 +1270,24 @@ async def _update_gremlin_graph_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_gremlin_graph_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_gremlin_graph_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + content_type=content_type, + json=_json, + template_url=self._update_gremlin_graph_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1399,8 +1303,11 @@ async def _update_gremlin_graph_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_gremlin_graph_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_gremlin_graph_throughput( self, resource_group_name: str, @@ -1422,18 +1329,24 @@ async def begin_update_gremlin_graph_throughput( :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current Gremlin graph. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1447,29 +1360,21 @@ async def begin_update_gremlin_graph_throughput( database_name=database_name, graph_name=graph_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1481,6 +1386,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_gremlin_graph_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default'} # type: ignore async def _migrate_gremlin_graph_to_autoscale_initial( @@ -1496,29 +1402,19 @@ async def _migrate_gremlin_graph_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_gremlin_graph_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_gremlin_graph_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self._migrate_gremlin_graph_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1534,8 +1430,11 @@ async def _migrate_gremlin_graph_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_gremlin_graph_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_gremlin_graph_to_autoscale( self, resource_group_name: str, @@ -1556,15 +1455,19 @@ async def begin_migrate_gremlin_graph_to_autoscale( :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1580,26 +1483,17 @@ async def begin_migrate_gremlin_graph_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1611,6 +1505,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_gremlin_graph_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_gremlin_graph_to_manual_throughput_initial( @@ -1626,29 +1521,19 @@ async def _migrate_gremlin_graph_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_gremlin_graph_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_gremlin_graph_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self._migrate_gremlin_graph_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1664,8 +1549,11 @@ async def _migrate_gremlin_graph_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_gremlin_graph_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_gremlin_graph_to_manual_throughput( self, resource_group_name: str, @@ -1686,15 +1574,19 @@ async def begin_migrate_gremlin_graph_to_manual_throughput( :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1710,26 +1602,17 @@ async def begin_migrate_gremlin_graph_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1741,4 +1624,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_gremlin_graph_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_locations_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_locations_operations.py index bff2c5e3c5748..cd74ef49eb954 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_locations_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_locations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._locations_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -57,34 +63,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,11 +103,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations'} # type: ignore + @distributed_trace_async async def get( self, location: str, @@ -126,26 +129,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,4 +152,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}'} # type: ignore + diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_mongo_db_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_mongo_db_resources_operations.py index f1e61dd74645a..3dc25a56ba699 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_mongo_db_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_mongo_db_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._mongo_db_resources_operations import build_create_update_mongo_db_collection_request_initial, build_create_update_mongo_db_database_request_initial, build_delete_mongo_db_collection_request_initial, build_delete_mongo_db_database_request_initial, build_get_mongo_db_collection_request, build_get_mongo_db_collection_throughput_request, build_get_mongo_db_database_request, build_get_mongo_db_database_throughput_request, build_list_mongo_db_collections_request, build_list_mongo_db_databases_request, build_migrate_mongo_db_collection_to_autoscale_request_initial, build_migrate_mongo_db_collection_to_manual_throughput_request_initial, build_migrate_mongo_db_database_to_autoscale_request_initial, build_migrate_mongo_db_database_to_manual_throughput_request_initial, build_retrieve_continuous_backup_information_request_initial, build_update_mongo_db_collection_throughput_request_initial, build_update_mongo_db_database_throughput_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_mongo_db_databases( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list_mongo_db_databases( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MongoDBDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBDatabaseListResult] + :return: An iterator like instance of either MongoDBDatabaseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MongoDBDatabaseListResult"] @@ -65,36 +73,33 @@ def list_mongo_db_databases( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_mongo_db_databases.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_mongo_db_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_mongo_db_databases.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_mongo_db_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MongoDBDatabaseListResult', pipeline_response) + deserialized = self._deserialize("MongoDBDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,11 +117,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_mongo_db_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases'} # type: ignore + @distributed_trace_async async def get_mongo_db_database( self, resource_group_name: str, @@ -143,28 +150,18 @@ async def get_mongo_db_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_mongo_db_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_mongo_db_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_mongo_db_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -178,8 +175,10 @@ async def get_mongo_db_database( return cls(pipeline_response, deserialized, {}) return deserialized + get_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore + async def _create_update_mongo_db_database_initial( self, resource_group_name: str, @@ -193,33 +192,23 @@ async def _create_update_mongo_db_database_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_mongo_db_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_mongo_db_database_parameters, 'MongoDBDatabaseCreateUpdateParameters') + + request = build_create_update_mongo_db_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._create_update_mongo_db_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_mongo_db_database_parameters, 'MongoDBDatabaseCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def _create_update_mongo_db_database_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_mongo_db_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_mongo_db_database( self, resource_group_name: str, @@ -255,18 +247,24 @@ async def begin_create_update_mongo_db_database( :type database_name: str :param create_update_mongo_db_database_parameters: The parameters to provide for the current MongoDB database. - :type create_update_mongo_db_database_parameters: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseCreateUpdateParameters + :type create_update_mongo_db_database_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBDatabaseCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MongoDBDatabaseGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MongoDBDatabaseGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MongoDBDatabaseGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +277,21 @@ async def begin_create_update_mongo_db_database( account_name=account_name, database_name=database_name, create_update_mongo_db_database_parameters=create_update_mongo_db_database_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MongoDBDatabaseGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -312,6 +303,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore async def _delete_mongo_db_database_initial( @@ -326,26 +318,18 @@ async def _delete_mongo_db_database_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_mongo_db_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_mongo_db_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._delete_mongo_db_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -358,6 +342,8 @@ async def _delete_mongo_db_database_initial( _delete_mongo_db_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_delete_mongo_db_database( self, resource_group_name: str, @@ -375,15 +361,17 @@ async def begin_delete_mongo_db_database( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -398,22 +386,14 @@ async def begin_delete_mongo_db_database( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -425,8 +405,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore + @distributed_trace_async async def get_mongo_db_database_throughput( self, resource_group_name: str, @@ -453,28 +435,18 @@ async def get_mongo_db_database_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_mongo_db_database_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_mongo_db_database_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_mongo_db_database_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -488,8 +460,10 @@ async def get_mongo_db_database_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_mongo_db_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default'} # type: ignore + async def _update_mongo_db_database_throughput_initial( self, resource_group_name: str, @@ -503,33 +477,23 @@ async def _update_mongo_db_database_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_mongo_db_database_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_mongo_db_database_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._update_mongo_db_database_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -545,8 +509,11 @@ async def _update_mongo_db_database_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_mongo_db_database_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_mongo_db_database_throughput( self, resource_group_name: str, @@ -565,18 +532,24 @@ async def begin_update_mongo_db_database_throughput( :type database_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current MongoDB database. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -589,28 +562,21 @@ async def begin_update_mongo_db_database_throughput( account_name=account_name, database_name=database_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -622,6 +588,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_mongo_db_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default'} # type: ignore async def _migrate_mongo_db_database_to_autoscale_initial( @@ -636,28 +603,18 @@ async def _migrate_mongo_db_database_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_mongo_db_database_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_mongo_db_database_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_mongo_db_database_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -673,8 +630,11 @@ async def _migrate_mongo_db_database_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_mongo_db_database_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_mongo_db_database_to_autoscale( self, resource_group_name: str, @@ -692,15 +652,19 @@ async def begin_migrate_mongo_db_database_to_autoscale( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -715,25 +679,17 @@ async def begin_migrate_mongo_db_database_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -745,6 +701,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_mongo_db_database_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_mongo_db_database_to_manual_throughput_initial( @@ -759,28 +716,18 @@ async def _migrate_mongo_db_database_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_mongo_db_database_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_mongo_db_database_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_mongo_db_database_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -796,8 +743,11 @@ async def _migrate_mongo_db_database_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_mongo_db_database_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_mongo_db_database_to_manual_throughput( self, resource_group_name: str, @@ -815,15 +765,19 @@ async def begin_migrate_mongo_db_database_to_manual_throughput( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -838,25 +792,17 @@ async def begin_migrate_mongo_db_database_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -868,8 +814,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_mongo_db_database_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_mongo_db_collections( self, resource_group_name: str, @@ -886,8 +834,10 @@ def list_mongo_db_collections( :param database_name: Cosmos DB database name. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MongoDBCollectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionListResult] + :return: An iterator like instance of either MongoDBCollectionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MongoDBCollectionListResult"] @@ -895,37 +845,35 @@ def list_mongo_db_collections( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_mongo_db_collections.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_mongo_db_collections_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.list_mongo_db_collections.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_mongo_db_collections_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("MongoDBCollectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -943,11 +891,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_mongo_db_collections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections'} # type: ignore + @distributed_trace_async async def get_mongo_db_collection( self, resource_group_name: str, @@ -976,29 +926,19 @@ async def get_mongo_db_collection( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_mongo_db_collection.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_mongo_db_collection_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self.get_mongo_db_collection.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1012,8 +952,10 @@ async def get_mongo_db_collection( return cls(pipeline_response, deserialized, {}) return deserialized + get_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore + async def _create_update_mongo_db_collection_initial( self, resource_group_name: str, @@ -1028,34 +970,24 @@ async def _create_update_mongo_db_collection_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_mongo_db_collection_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_mongo_db_collection_parameters, 'MongoDBCollectionCreateUpdateParameters') + + request = build_create_update_mongo_db_collection_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + content_type=content_type, + json=_json, + template_url=self._create_update_mongo_db_collection_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_mongo_db_collection_parameters, 'MongoDBCollectionCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1071,8 +1003,11 @@ async def _create_update_mongo_db_collection_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_mongo_db_collection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_mongo_db_collection( self, resource_group_name: str, @@ -1094,18 +1029,24 @@ async def begin_create_update_mongo_db_collection( :type collection_name: str :param create_update_mongo_db_collection_parameters: The parameters to provide for the current MongoDB Collection. - :type create_update_mongo_db_collection_parameters: ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters + :type create_update_mongo_db_collection_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MongoDBCollectionGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MongoDBCollectionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MongoDBCollectionGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1119,29 +1060,21 @@ async def begin_create_update_mongo_db_collection( database_name=database_name, collection_name=collection_name, create_update_mongo_db_collection_parameters=create_update_mongo_db_collection_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MongoDBCollectionGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1153,6 +1086,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore async def _delete_mongo_db_collection_initial( @@ -1168,27 +1102,19 @@ async def _delete_mongo_db_collection_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_mongo_db_collection_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_mongo_db_collection_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self._delete_mongo_db_collection_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1201,6 +1127,8 @@ async def _delete_mongo_db_collection_initial( _delete_mongo_db_collection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete_mongo_db_collection( self, resource_group_name: str, @@ -1221,15 +1149,17 @@ async def begin_delete_mongo_db_collection( :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1245,23 +1175,14 @@ async def begin_delete_mongo_db_collection( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1273,8 +1194,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore + @distributed_trace_async async def get_mongo_db_collection_throughput( self, resource_group_name: str, @@ -1304,29 +1227,19 @@ async def get_mongo_db_collection_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_mongo_db_collection_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_mongo_db_collection_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self.get_mongo_db_collection_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1340,8 +1253,10 @@ async def get_mongo_db_collection_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_mongo_db_collection_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default'} # type: ignore + async def _update_mongo_db_collection_throughput_initial( self, resource_group_name: str, @@ -1356,34 +1271,24 @@ async def _update_mongo_db_collection_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_mongo_db_collection_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_mongo_db_collection_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + content_type=content_type, + json=_json, + template_url=self._update_mongo_db_collection_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1399,8 +1304,11 @@ async def _update_mongo_db_collection_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_mongo_db_collection_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_mongo_db_collection_throughput( self, resource_group_name: str, @@ -1422,18 +1330,24 @@ async def begin_update_mongo_db_collection_throughput( :type collection_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current MongoDB collection. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1447,29 +1361,21 @@ async def begin_update_mongo_db_collection_throughput( database_name=database_name, collection_name=collection_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1481,6 +1387,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_mongo_db_collection_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default'} # type: ignore async def _migrate_mongo_db_collection_to_autoscale_initial( @@ -1496,29 +1403,19 @@ async def _migrate_mongo_db_collection_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_mongo_db_collection_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_mongo_db_collection_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self._migrate_mongo_db_collection_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1534,8 +1431,11 @@ async def _migrate_mongo_db_collection_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_mongo_db_collection_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_mongo_db_collection_to_autoscale( self, resource_group_name: str, @@ -1556,15 +1456,19 @@ async def begin_migrate_mongo_db_collection_to_autoscale( :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1580,26 +1484,17 @@ async def begin_migrate_mongo_db_collection_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1611,6 +1506,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_mongo_db_collection_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_mongo_db_collection_to_manual_throughput_initial( @@ -1626,29 +1522,19 @@ async def _migrate_mongo_db_collection_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_mongo_db_collection_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_mongo_db_collection_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self._migrate_mongo_db_collection_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1664,8 +1550,11 @@ async def _migrate_mongo_db_collection_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_mongo_db_collection_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_mongo_db_collection_to_manual_throughput( self, resource_group_name: str, @@ -1686,15 +1575,19 @@ async def begin_migrate_mongo_db_collection_to_manual_throughput( :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1710,26 +1603,17 @@ async def begin_migrate_mongo_db_collection_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1741,6 +1625,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_mongo_db_collection_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore async def _retrieve_continuous_backup_information_initial( @@ -1757,34 +1642,24 @@ async def _retrieve_continuous_backup_information_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._retrieve_continuous_backup_information_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_retrieve_continuous_backup_information_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + content_type=content_type, + json=_json, + template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(location, 'ContinuousBackupRestoreLocation') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1800,8 +1675,11 @@ async def _retrieve_continuous_backup_information_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _retrieve_continuous_backup_information_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation'} # type: ignore + + @distributed_trace_async async def begin_retrieve_continuous_backup_information( self, resource_group_name: str, @@ -1825,15 +1703,19 @@ async def begin_retrieve_continuous_backup_information( :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInformation"] lro_delay = kwargs.pop( 'polling_interval', @@ -1847,29 +1729,21 @@ async def begin_retrieve_continuous_backup_information( database_name=database_name, collection_name=collection_name, location=location, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BackupInformation', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1881,4 +1755,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_retrieve_continuous_backup_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_notebook_workspaces_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_notebook_workspaces_operations.py index 3b20c59ac4440..c123b64906f55 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_notebook_workspaces_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_notebook_workspaces_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._notebook_workspaces_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_database_account_request, build_list_connection_info_request, build_regenerate_auth_token_request_initial, build_start_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database_account( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list_by_database_account( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NotebookWorkspaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.NotebookWorkspaceListResult] + :return: An iterator like instance of either NotebookWorkspaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.NotebookWorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.NotebookWorkspaceListResult"] @@ -65,36 +73,33 @@ def list_by_database_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_by_database_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NotebookWorkspaceListResult', pipeline_response) + deserialized = self._deserialize("NotebookWorkspaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,17 +112,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) list_by_database_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -143,34 +150,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NotebookWorkspace', pipeline_response) @@ -179,8 +176,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -194,40 +193,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(notebook_create_update_parameters, 'NotebookWorkspaceCreateUpdateParameters') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(notebook_create_update_parameters, 'NotebookWorkspaceCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('NotebookWorkspace', pipeline_response) @@ -235,8 +223,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -255,18 +246,23 @@ async def begin_create_or_update( :type notebook_workspace_name: str or ~azure.mgmt.cosmosdb.models.NotebookWorkspaceName :param notebook_create_update_parameters: The notebook workspace to create for the current database account. - :type notebook_create_update_parameters: ~azure.mgmt.cosmosdb.models.NotebookWorkspaceCreateUpdateParameters + :type notebook_create_update_parameters: + ~azure.mgmt.cosmosdb.models.NotebookWorkspaceCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either NotebookWorkspace or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either NotebookWorkspace or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.NotebookWorkspace] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.NotebookWorkspace"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +275,21 @@ async def begin_create_or_update( account_name=account_name, notebook_workspace_name=notebook_workspace_name, notebook_create_update_parameters=notebook_create_update_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('NotebookWorkspace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -312,6 +301,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore async def _delete_initial( @@ -326,41 +316,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -378,15 +359,17 @@ async def begin_delete( :type notebook_workspace_name: str or ~azure.mgmt.cosmosdb.models.NotebookWorkspaceName :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -401,22 +384,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -428,8 +403,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore + @distributed_trace_async async def list_connection_info( self, resource_group_name: str, @@ -455,34 +432,24 @@ async def list_connection_info( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.list_connection_info.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_connection_info_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self.list_connection_info.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NotebookWorkspaceConnectionInfoResult', pipeline_response) @@ -491,8 +458,10 @@ async def list_connection_info( return cls(pipeline_response, deserialized, {}) return deserialized + list_connection_info.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo'} # type: ignore + async def _regenerate_auth_token_initial( self, resource_group_name: str, @@ -505,41 +474,32 @@ async def _regenerate_auth_token_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._regenerate_auth_token_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_regenerate_auth_token_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self._regenerate_auth_token_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _regenerate_auth_token_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken'} # type: ignore + + @distributed_trace_async async def begin_regenerate_auth_token( self, resource_group_name: str, @@ -557,15 +517,17 @@ async def begin_regenerate_auth_token( :type notebook_workspace_name: str or ~azure.mgmt.cosmosdb.models.NotebookWorkspaceName :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -580,22 +542,14 @@ async def begin_regenerate_auth_token( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -607,6 +561,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_regenerate_auth_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken'} # type: ignore async def _start_initial( @@ -621,41 +576,32 @@ async def _start_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start'} # type: ignore + + @distributed_trace_async async def begin_start( self, resource_group_name: str, @@ -673,15 +619,17 @@ async def begin_start( :type notebook_workspace_name: str or ~azure.mgmt.cosmosdb.models.NotebookWorkspaceName :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -696,22 +644,14 @@ async def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -723,4 +663,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_operations.py index fc014cbffbfcc..5c0f0a2a4ba70 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_partition_key_range_id_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_partition_key_range_id_operations.py index 39b9d129a2fa3..cd92d9e3d639e 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_partition_key_range_id_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_partition_key_range_id_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._partition_key_range_id_operations import build_list_metrics_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -68,8 +74,10 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionMetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] + :return: An iterator like instance of either PartitionMetricListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PartitionMetricListResult"] @@ -77,40 +85,41 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - 'partitionKeyRangeId': self._serialize.url("partition_key_range_id", partition_key_range_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + partition_key_range_id=partition_key_range_id, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + partition_key_range_id=partition_key_range_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionMetricListResult', pipeline_response) + deserialized = self._deserialize("PartitionMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,6 +137,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_partition_key_range_id_region_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_partition_key_range_id_region_operations.py index a253dc497cab8..aa7a6a2ae40d6 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_partition_key_range_id_region_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_partition_key_range_id_region_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._partition_key_range_id_region_operations import build_list_metrics_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -72,8 +78,10 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionMetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] + :return: An iterator like instance of either PartitionMetricListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PartitionMetricListResult"] @@ -81,41 +89,43 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'region': self._serialize.url("region", region, 'str'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - 'partitionKeyRangeId': self._serialize.url("partition_key_range_id", partition_key_range_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + partition_key_range_id=partition_key_range_id, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + partition_key_range_id=partition_key_range_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionMetricListResult', pipeline_response) + deserialized = self._deserialize("PartitionMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,6 +143,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_operations.py index 015102bfc6758..2fb502ac05495 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._percentile_operations import build_list_metrics_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -60,8 +66,10 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PercentileMetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] + :return: An iterator like instance of either PercentileMetricListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PercentileMetricListResult"] @@ -69,37 +77,35 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PercentileMetricListResult', pipeline_response) + deserialized = self._deserialize("PercentileMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,6 +123,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_source_target_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_source_target_operations.py index 71802da95a1a5..d88922fbe9aa8 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_source_target_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_source_target_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._percentile_source_target_operations import build_list_metrics_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -68,8 +74,10 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PercentileMetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] + :return: An iterator like instance of either PercentileMetricListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PercentileMetricListResult"] @@ -77,39 +85,39 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'sourceRegion': self._serialize.url("source_region", source_region, 'str'), - 'targetRegion': self._serialize.url("target_region", target_region, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + source_region=source_region, + target_region=target_region, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + source_region=source_region, + target_region=target_region, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PercentileMetricListResult', pipeline_response) + deserialized = self._deserialize("PercentileMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,6 +135,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_target_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_target_operations.py index fb0855e1ac1d7..8c5d0ca6bebf1 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_target_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_percentile_target_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._percentile_target_operations import build_list_metrics_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, resource_group_name: str, @@ -64,8 +70,10 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PercentileMetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] + :return: An iterator like instance of either PercentileMetricListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PercentileMetricListResult"] @@ -73,38 +81,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'targetRegion': self._serialize.url("target_region", target_region, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + target_region=target_region, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + target_region=target_region, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PercentileMetricListResult', pipeline_response) + deserialized = self._deserialize("PercentileMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,6 +129,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_private_endpoint_connections_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_private_endpoint_connections_operations.py index dfda72c8fb6c0..ffecdd4a859e3 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_private_endpoint_connections_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_database_account_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database_account( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list_by_database_account( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -65,36 +73,33 @@ def list_by_database_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_by_database_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,11 +117,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_database_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -142,28 +149,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,8 +174,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -192,40 +191,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -235,8 +223,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -257,15 +248,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.cosmosdb.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -278,28 +274,21 @@ async def begin_create_or_update( account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -311,6 +300,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -325,41 +315,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -377,15 +358,17 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,22 +383,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -427,4 +402,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_private_link_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_private_link_resources_operations.py index b0234e9358cc7..9617454ef4e0a 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_private_link_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_private_link_resources_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_by_database_account_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database_account( self, resource_group_name: str, @@ -54,8 +60,10 @@ def list_by_database_account( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PrivateLinkResourceListResult] + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] @@ -63,36 +71,33 @@ def list_by_database_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_by_database_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,11 +115,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_database_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -140,28 +147,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + group_name=group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -175,4 +172,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}'} # type: ignore + diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_database_accounts_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_database_accounts_operations.py index 4d5837a758fe3..b7af1e5dd8f3c 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_database_accounts_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_database_accounts_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_database_accounts_operations import build_get_by_location_request, build_list_by_location_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_location( self, location: str, @@ -53,8 +59,10 @@ def list_by_location( :param location: Cosmos DB region, with spaces between words and each word capitalized. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDatabaseAccountsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] + :return: An iterator like instance of either RestorableDatabaseAccountsListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDatabaseAccountsListResult"] @@ -62,35 +70,31 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableDatabaseAccountsListResult', pipeline_response) + deserialized = self._deserialize("RestorableDatabaseAccountsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,11 +112,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -121,8 +127,10 @@ def list( This call requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDatabaseAccountsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] + :return: An iterator like instance of either RestorableDatabaseAccountsListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDatabaseAccountsListResult"] @@ -130,34 +138,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableDatabaseAccountsListResult', pipeline_response) + deserialized = self._deserialize("RestorableDatabaseAccountsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +178,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts'} # type: ignore + @distributed_trace_async async def get_by_location( self, location: str, @@ -203,27 +208,17 @@ async def get_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=self.get_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -237,4 +232,6 @@ async def get_by_location( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}'} # type: ignore + diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_collections_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_collections_operations.py index fbde445be87bf..88b58b74688ae 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_collections_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_collections_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_mongodb_collections_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, location: str, @@ -59,8 +65,10 @@ def list( :param restorable_mongodb_database_rid: The resource ID of the MongoDB database. :type restorable_mongodb_database_rid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableMongodbCollectionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionsListResult] + :return: An iterator like instance of either RestorableMongodbCollectionsListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableMongodbCollectionsListResult"] @@ -68,38 +76,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if restorable_mongodb_database_rid is not None: - query_parameters['restorableMongodbDatabaseRid'] = self._serialize.query("restorable_mongodb_database_rid", restorable_mongodb_database_rid, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restorable_mongodb_database_rid=restorable_mongodb_database_rid, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restorable_mongodb_database_rid=restorable_mongodb_database_rid, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableMongodbCollectionsListResult', pipeline_response) + deserialized = self._deserialize("RestorableMongodbCollectionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,6 +122,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_databases_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_databases_operations.py index 5ad38cfbb2fab..d8140473df8f8 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_databases_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_databases_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_mongodb_databases_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, location: str, @@ -57,8 +63,10 @@ def list( :param instance_id: The instanceId GUID of a restorable database account. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableMongodbDatabasesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasesListResult] + :return: An iterator like instance of either RestorableMongodbDatabasesListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableMongodbDatabasesListResult"] @@ -66,36 +74,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableMongodbDatabasesListResult', pipeline_response) + deserialized = self._deserialize("RestorableMongodbDatabasesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,6 +118,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_resources_operations.py index d9196855b756d..b0d5c7c4af4d2 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_mongodb_resources_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_mongodb_resources_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, location: str, @@ -63,8 +69,10 @@ def list( :param restore_timestamp_in_utc: The timestamp when the restorable resources existed. :type restore_timestamp_in_utc: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableMongodbResourcesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesListResult] + :return: An iterator like instance of either RestorableMongodbResourcesListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableMongodbResourcesListResult"] @@ -72,40 +80,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if restore_location is not None: - query_parameters['restoreLocation'] = self._serialize.query("restore_location", restore_location, 'str') - if restore_timestamp_in_utc is not None: - query_parameters['restoreTimestampInUtc'] = self._serialize.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restore_location=restore_location, + restore_timestamp_in_utc=restore_timestamp_in_utc, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restore_location=restore_location, + restore_timestamp_in_utc=restore_timestamp_in_utc, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableMongodbResourcesListResult', pipeline_response) + deserialized = self._deserialize("RestorableMongodbResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -123,6 +128,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_containers_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_containers_operations.py index c676cfc68a2d3..4a2f5015c2fb5 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_containers_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_containers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_sql_containers_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, location: str, @@ -65,8 +71,10 @@ def list( :param end_time: The snapshot create timestamp before which snapshots need to be listed. :type end_time: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableSqlContainersListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlContainersListResult] + :return: An iterator like instance of either RestorableSqlContainersListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlContainersListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableSqlContainersListResult"] @@ -74,42 +82,39 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if restorable_sql_database_rid is not None: - query_parameters['restorableSqlDatabaseRid'] = self._serialize.query("restorable_sql_database_rid", restorable_sql_database_rid, 'str') - if start_time is not None: - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - if end_time is not None: - query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restorable_sql_database_rid=restorable_sql_database_rid, + start_time=start_time, + end_time=end_time, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restorable_sql_database_rid=restorable_sql_database_rid, + start_time=start_time, + end_time=end_time, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableSqlContainersListResult', pipeline_response) + deserialized = self._deserialize("RestorableSqlContainersListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,6 +132,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_databases_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_databases_operations.py index ea9954e37e2b6..7929c58d814bb 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_databases_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_databases_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_sql_databases_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, location: str, @@ -57,8 +63,10 @@ def list( :param instance_id: The instanceId GUID of a restorable database account. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableSqlDatabasesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlDatabasesListResult] + :return: An iterator like instance of either RestorableSqlDatabasesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlDatabasesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableSqlDatabasesListResult"] @@ -66,36 +74,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableSqlDatabasesListResult', pipeline_response) + deserialized = self._deserialize("RestorableSqlDatabasesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,6 +118,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_resources_operations.py index cc7e6e7665ebd..86755646c35dc 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_sql_resources_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._restorable_sql_resources_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, location: str, @@ -63,8 +69,10 @@ def list( :param restore_timestamp_in_utc: The timestamp when the restorable resources existed. :type restore_timestamp_in_utc: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableSqlResourcesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesListResult] + :return: An iterator like instance of either RestorableSqlResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableSqlResourcesListResult"] @@ -72,40 +80,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if restore_location is not None: - query_parameters['restoreLocation'] = self._serialize.query("restore_location", restore_location, 'str') - if restore_timestamp_in_utc is not None: - query_parameters['restoreTimestampInUtc'] = self._serialize.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restore_location=restore_location, + restore_timestamp_in_utc=restore_timestamp_in_utc, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restore_location=restore_location, + restore_timestamp_in_utc=restore_timestamp_in_utc, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableSqlResourcesListResult', pipeline_response) + deserialized = self._deserialize("RestorableSqlResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -123,6 +128,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_sql_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_sql_resources_operations.py index 2c260024a7136..8df915fb42baa 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_sql_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_sql_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._sql_resources_operations import build_create_update_sql_container_request_initial, build_create_update_sql_database_request_initial, build_create_update_sql_role_assignment_request_initial, build_create_update_sql_role_definition_request_initial, build_create_update_sql_stored_procedure_request_initial, build_create_update_sql_trigger_request_initial, build_create_update_sql_user_defined_function_request_initial, build_delete_sql_container_request_initial, build_delete_sql_database_request_initial, build_delete_sql_role_assignment_request_initial, build_delete_sql_role_definition_request_initial, build_delete_sql_stored_procedure_request_initial, build_delete_sql_trigger_request_initial, build_delete_sql_user_defined_function_request_initial, build_get_sql_container_request, build_get_sql_container_throughput_request, build_get_sql_database_request, build_get_sql_database_throughput_request, build_get_sql_role_assignment_request, build_get_sql_role_definition_request, build_get_sql_stored_procedure_request, build_get_sql_trigger_request, build_get_sql_user_defined_function_request, build_list_sql_containers_request, build_list_sql_databases_request, build_list_sql_role_assignments_request, build_list_sql_role_definitions_request, build_list_sql_stored_procedures_request, build_list_sql_triggers_request, build_list_sql_user_defined_functions_request, build_migrate_sql_container_to_autoscale_request_initial, build_migrate_sql_container_to_manual_throughput_request_initial, build_migrate_sql_database_to_autoscale_request_initial, build_migrate_sql_database_to_manual_throughput_request_initial, build_retrieve_continuous_backup_information_request_initial, build_update_sql_container_throughput_request_initial, build_update_sql_database_throughput_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_sql_databases( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list_sql_databases( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlDatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlDatabaseListResult] + :return: An iterator like instance of either SqlDatabaseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlDatabaseListResult"] @@ -65,36 +73,33 @@ def list_sql_databases( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_databases.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_sql_databases.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SqlDatabaseListResult', pipeline_response) + deserialized = self._deserialize("SqlDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,11 +117,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_sql_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases'} # type: ignore + @distributed_trace_async async def get_sql_database( self, resource_group_name: str, @@ -143,28 +150,18 @@ async def get_sql_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_sql_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -178,8 +175,10 @@ async def get_sql_database( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore + async def _create_update_sql_database_initial( self, resource_group_name: str, @@ -193,33 +192,23 @@ async def _create_update_sql_database_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_sql_database_parameters, 'SqlDatabaseCreateUpdateParameters') + + request = build_create_update_sql_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_database_parameters, 'SqlDatabaseCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def _create_update_sql_database_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_sql_database( self, resource_group_name: str, @@ -255,18 +247,23 @@ async def begin_create_update_sql_database( :type database_name: str :param create_update_sql_database_parameters: The parameters to provide for the current SQL database. - :type create_update_sql_database_parameters: ~azure.mgmt.cosmosdb.models.SqlDatabaseCreateUpdateParameters + :type create_update_sql_database_parameters: + ~azure.mgmt.cosmosdb.models.SqlDatabaseCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlDatabaseGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlDatabaseGetResults or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlDatabaseGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +276,21 @@ async def begin_create_update_sql_database( account_name=account_name, database_name=database_name, create_update_sql_database_parameters=create_update_sql_database_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlDatabaseGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -312,6 +302,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore async def _delete_sql_database_initial( @@ -326,26 +317,18 @@ async def _delete_sql_database_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._delete_sql_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -358,6 +341,8 @@ async def _delete_sql_database_initial( _delete_sql_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore + + @distributed_trace_async async def begin_delete_sql_database( self, resource_group_name: str, @@ -375,15 +360,17 @@ async def begin_delete_sql_database( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -398,22 +385,14 @@ async def begin_delete_sql_database( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -425,8 +404,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore + @distributed_trace_async async def get_sql_database_throughput( self, resource_group_name: str, @@ -453,28 +434,18 @@ async def get_sql_database_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_database_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_database_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_sql_database_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -488,8 +459,10 @@ async def get_sql_database_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default'} # type: ignore + async def _update_sql_database_throughput_initial( self, resource_group_name: str, @@ -503,33 +476,23 @@ async def _update_sql_database_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_sql_database_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_sql_database_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._update_sql_database_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -545,8 +508,11 @@ async def _update_sql_database_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_sql_database_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_sql_database_throughput( self, resource_group_name: str, @@ -565,18 +531,24 @@ async def begin_update_sql_database_throughput( :type database_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the current SQL database. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -589,28 +561,21 @@ async def begin_update_sql_database_throughput( account_name=account_name, database_name=database_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -622,6 +587,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_sql_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default'} # type: ignore async def _migrate_sql_database_to_autoscale_initial( @@ -636,28 +602,18 @@ async def _migrate_sql_database_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_sql_database_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_sql_database_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_sql_database_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -673,8 +629,11 @@ async def _migrate_sql_database_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_sql_database_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_sql_database_to_autoscale( self, resource_group_name: str, @@ -692,15 +651,19 @@ async def begin_migrate_sql_database_to_autoscale( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -715,25 +678,17 @@ async def begin_migrate_sql_database_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -745,6 +700,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_sql_database_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_sql_database_to_manual_throughput_initial( @@ -759,28 +715,18 @@ async def _migrate_sql_database_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_sql_database_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_sql_database_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_sql_database_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -796,8 +742,11 @@ async def _migrate_sql_database_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_sql_database_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_sql_database_to_manual_throughput( self, resource_group_name: str, @@ -815,15 +764,19 @@ async def begin_migrate_sql_database_to_manual_throughput( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -838,25 +791,17 @@ async def begin_migrate_sql_database_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -868,8 +813,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_sql_database_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_sql_containers( self, resource_group_name: str, @@ -886,8 +833,10 @@ def list_sql_containers( :param database_name: Cosmos DB database name. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlContainerListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerListResult] + :return: An iterator like instance of either SqlContainerListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlContainerListResult"] @@ -895,37 +844,35 @@ def list_sql_containers( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_containers.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_containers_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.list_sql_containers.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_containers_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SqlContainerListResult', pipeline_response) + deserialized = self._deserialize("SqlContainerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -943,11 +890,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_sql_containers.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers'} # type: ignore + @distributed_trace_async async def get_sql_container( self, resource_group_name: str, @@ -976,29 +925,19 @@ async def get_sql_container( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_container.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_container_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.get_sql_container.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1012,8 +951,10 @@ async def get_sql_container( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_container.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore + async def _create_update_sql_container_initial( self, resource_group_name: str, @@ -1028,34 +969,24 @@ async def _create_update_sql_container_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_container_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_sql_container_parameters, 'SqlContainerCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_sql_container_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_container_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_container_parameters, 'SqlContainerCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1071,8 +1002,11 @@ async def _create_update_sql_container_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_container_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_sql_container( self, resource_group_name: str, @@ -1094,18 +1028,23 @@ async def begin_create_update_sql_container( :type container_name: str :param create_update_sql_container_parameters: The parameters to provide for the current SQL container. - :type create_update_sql_container_parameters: ~azure.mgmt.cosmosdb.models.SqlContainerCreateUpdateParameters + :type create_update_sql_container_parameters: + ~azure.mgmt.cosmosdb.models.SqlContainerCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlContainerGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlContainerGetResults or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlContainerGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1119,29 +1058,21 @@ async def begin_create_update_sql_container( database_name=database_name, container_name=container_name, create_update_sql_container_parameters=create_update_sql_container_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlContainerGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1153,6 +1084,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_container.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore async def _delete_sql_container_initial( @@ -1168,27 +1100,19 @@ async def _delete_sql_container_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_container_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_container_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self._delete_sql_container_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1201,6 +1125,8 @@ async def _delete_sql_container_initial( _delete_sql_container_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore + + @distributed_trace_async async def begin_delete_sql_container( self, resource_group_name: str, @@ -1221,15 +1147,17 @@ async def begin_delete_sql_container( :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1245,23 +1173,14 @@ async def begin_delete_sql_container( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1273,8 +1192,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_container.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore + @distributed_trace_async async def get_sql_container_throughput( self, resource_group_name: str, @@ -1304,29 +1225,19 @@ async def get_sql_container_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_container_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_container_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.get_sql_container_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1340,8 +1251,10 @@ async def get_sql_container_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_container_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default'} # type: ignore + async def _update_sql_container_throughput_initial( self, resource_group_name: str, @@ -1356,34 +1269,24 @@ async def _update_sql_container_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_sql_container_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_sql_container_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + content_type=content_type, + json=_json, + template_url=self._update_sql_container_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1399,8 +1302,11 @@ async def _update_sql_container_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_sql_container_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_sql_container_throughput( self, resource_group_name: str, @@ -1422,18 +1328,24 @@ async def begin_update_sql_container_throughput( :type container_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the current SQL container. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1447,29 +1359,21 @@ async def begin_update_sql_container_throughput( database_name=database_name, container_name=container_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1481,6 +1385,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_sql_container_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default'} # type: ignore async def _migrate_sql_container_to_autoscale_initial( @@ -1496,29 +1401,19 @@ async def _migrate_sql_container_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_sql_container_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_sql_container_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self._migrate_sql_container_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1534,8 +1429,11 @@ async def _migrate_sql_container_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_sql_container_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_sql_container_to_autoscale( self, resource_group_name: str, @@ -1556,15 +1454,19 @@ async def begin_migrate_sql_container_to_autoscale( :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1580,26 +1482,17 @@ async def begin_migrate_sql_container_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1611,6 +1504,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_sql_container_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_sql_container_to_manual_throughput_initial( @@ -1626,29 +1520,19 @@ async def _migrate_sql_container_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_sql_container_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_sql_container_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self._migrate_sql_container_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1664,8 +1548,11 @@ async def _migrate_sql_container_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_sql_container_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_sql_container_to_manual_throughput( self, resource_group_name: str, @@ -1686,15 +1573,19 @@ async def begin_migrate_sql_container_to_manual_throughput( :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1710,26 +1601,17 @@ async def begin_migrate_sql_container_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1741,8 +1623,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_sql_container_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_sql_stored_procedures( self, resource_group_name: str, @@ -1762,8 +1646,10 @@ def list_sql_stored_procedures( :param container_name: Cosmos DB container name. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlStoredProcedureListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureListResult] + :return: An iterator like instance of either SqlStoredProcedureListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlStoredProcedureListResult"] @@ -1771,38 +1657,37 @@ def list_sql_stored_procedures( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_stored_procedures.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_stored_procedures_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.list_sql_stored_procedures.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_stored_procedures_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("SqlStoredProcedureListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1820,11 +1705,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_sql_stored_procedures.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures'} # type: ignore + @distributed_trace_async async def get_sql_stored_procedure( self, resource_group_name: str, @@ -1856,30 +1743,20 @@ async def get_sql_stored_procedure( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_stored_procedure.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_stored_procedure_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + stored_procedure_name=stored_procedure_name, + template_url=self.get_sql_stored_procedure.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1893,8 +1770,10 @@ async def get_sql_stored_procedure( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore + async def _create_update_sql_stored_procedure_initial( self, resource_group_name: str, @@ -1910,35 +1789,25 @@ async def _create_update_sql_stored_procedure_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_stored_procedure_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_sql_stored_procedure_parameters, 'SqlStoredProcedureCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_sql_stored_procedure_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + stored_procedure_name=stored_procedure_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_stored_procedure_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_stored_procedure_parameters, 'SqlStoredProcedureCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1954,8 +1823,11 @@ async def _create_update_sql_stored_procedure_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_stored_procedure_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_sql_stored_procedure( self, resource_group_name: str, @@ -1980,18 +1852,24 @@ async def begin_create_update_sql_stored_procedure( :type stored_procedure_name: str :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current SQL storedProcedure. - :type create_update_sql_stored_procedure_parameters: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters + :type create_update_sql_stored_procedure_parameters: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlStoredProcedureGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -2006,30 +1884,21 @@ async def begin_create_update_sql_stored_procedure( container_name=container_name, stored_procedure_name=stored_procedure_name, create_update_sql_stored_procedure_parameters=create_update_sql_stored_procedure_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlStoredProcedureGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2041,6 +1910,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore async def _delete_sql_stored_procedure_initial( @@ -2057,28 +1927,20 @@ async def _delete_sql_stored_procedure_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_stored_procedure_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_stored_procedure_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + stored_procedure_name=stored_procedure_name, + template_url=self._delete_sql_stored_procedure_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2091,6 +1953,8 @@ async def _delete_sql_stored_procedure_initial( _delete_sql_stored_procedure_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore + + @distributed_trace_async async def begin_delete_sql_stored_procedure( self, resource_group_name: str, @@ -2114,15 +1978,17 @@ async def begin_delete_sql_stored_procedure( :type stored_procedure_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2139,24 +2005,14 @@ async def begin_delete_sql_stored_procedure( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2168,8 +2024,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore + @distributed_trace def list_sql_user_defined_functions( self, resource_group_name: str, @@ -2189,8 +2047,10 @@ def list_sql_user_defined_functions( :param container_name: Cosmos DB container name. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlUserDefinedFunctionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionListResult] + :return: An iterator like instance of either SqlUserDefinedFunctionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlUserDefinedFunctionListResult"] @@ -2198,38 +2058,37 @@ def list_sql_user_defined_functions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_user_defined_functions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_user_defined_functions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.list_sql_user_defined_functions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_user_defined_functions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SqlUserDefinedFunctionListResult', pipeline_response) + deserialized = self._deserialize("SqlUserDefinedFunctionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2247,11 +2106,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_sql_user_defined_functions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions'} # type: ignore + @distributed_trace_async async def get_sql_user_defined_function( self, resource_group_name: str, @@ -2283,30 +2144,20 @@ async def get_sql_user_defined_function( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_user_defined_function.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_user_defined_function_request( + subscription_id=self._config.subscription_id, + 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, + template_url=self.get_sql_user_defined_function.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2320,8 +2171,10 @@ async def get_sql_user_defined_function( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_user_defined_function.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore + async def _create_update_sql_user_defined_function_initial( self, resource_group_name: str, @@ -2337,35 +2190,25 @@ async def _create_update_sql_user_defined_function_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_user_defined_function_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_sql_user_defined_function_parameters, 'SqlUserDefinedFunctionCreateUpdateParameters') + + request = build_create_update_sql_user_defined_function_request_initial( + subscription_id=self._config.subscription_id, + 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, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_user_defined_function_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_user_defined_function_parameters, 'SqlUserDefinedFunctionCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2381,8 +2224,11 @@ async def _create_update_sql_user_defined_function_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_user_defined_function_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_sql_user_defined_function( self, resource_group_name: str, @@ -2407,18 +2253,24 @@ async def begin_create_update_sql_user_defined_function( :type user_defined_function_name: str :param create_update_sql_user_defined_function_parameters: The parameters to provide for the current SQL userDefinedFunction. - :type create_update_sql_user_defined_function_parameters: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionCreateUpdateParameters + :type create_update_sql_user_defined_function_parameters: + ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlUserDefinedFunctionGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlUserDefinedFunctionGetResults or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlUserDefinedFunctionGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -2433,30 +2285,21 @@ async def begin_create_update_sql_user_defined_function( container_name=container_name, user_defined_function_name=user_defined_function_name, create_update_sql_user_defined_function_parameters=create_update_sql_user_defined_function_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlUserDefinedFunctionGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2468,6 +2311,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_user_defined_function.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore async def _delete_sql_user_defined_function_initial( @@ -2484,28 +2328,20 @@ async def _delete_sql_user_defined_function_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_user_defined_function_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_user_defined_function_request_initial( + subscription_id=self._config.subscription_id, + 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, + template_url=self._delete_sql_user_defined_function_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2518,6 +2354,8 @@ async def _delete_sql_user_defined_function_initial( _delete_sql_user_defined_function_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore + + @distributed_trace_async async def begin_delete_sql_user_defined_function( self, resource_group_name: str, @@ -2541,15 +2379,17 @@ async def begin_delete_sql_user_defined_function( :type user_defined_function_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2566,24 +2406,14 @@ async def begin_delete_sql_user_defined_function( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2595,8 +2425,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_user_defined_function.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore + @distributed_trace def list_sql_triggers( self, resource_group_name: str, @@ -2616,8 +2448,10 @@ def list_sql_triggers( :param container_name: Cosmos DB container name. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlTriggerListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerListResult] + :return: An iterator like instance of either SqlTriggerListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlTriggerListResult"] @@ -2625,38 +2459,37 @@ def list_sql_triggers( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_triggers.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_triggers_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.list_sql_triggers.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_triggers_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=next_link, + ) + request = _convert_request(request) + 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) + deserialized = self._deserialize("SqlTriggerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2674,11 +2507,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_sql_triggers.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers'} # type: ignore + @distributed_trace_async async def get_sql_trigger( self, resource_group_name: str, @@ -2710,30 +2545,20 @@ async def get_sql_trigger( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_trigger.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_trigger_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + trigger_name=trigger_name, + template_url=self.get_sql_trigger.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2747,8 +2572,10 @@ async def get_sql_trigger( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore + async def _create_update_sql_trigger_initial( self, resource_group_name: str, @@ -2764,35 +2591,25 @@ async def _create_update_sql_trigger_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_trigger_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_sql_trigger_parameters, 'SqlTriggerCreateUpdateParameters') + + request = build_create_update_sql_trigger_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + trigger_name=trigger_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_trigger_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_trigger_parameters, 'SqlTriggerCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2808,8 +2625,11 @@ async def _create_update_sql_trigger_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_trigger_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_sql_trigger( self, resource_group_name: str, @@ -2834,18 +2654,23 @@ async def begin_create_update_sql_trigger( :type trigger_name: str :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL trigger. - :type create_update_sql_trigger_parameters: ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters + :type create_update_sql_trigger_parameters: + ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlTriggerGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlTriggerGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -2860,30 +2685,21 @@ async def begin_create_update_sql_trigger( container_name=container_name, trigger_name=trigger_name, create_update_sql_trigger_parameters=create_update_sql_trigger_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlTriggerGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2895,6 +2711,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore async def _delete_sql_trigger_initial( @@ -2911,28 +2728,20 @@ async def _delete_sql_trigger_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_trigger_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_trigger_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + trigger_name=trigger_name, + template_url=self._delete_sql_trigger_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2945,6 +2754,8 @@ async def _delete_sql_trigger_initial( _delete_sql_trigger_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore + + @distributed_trace_async async def begin_delete_sql_trigger( self, resource_group_name: str, @@ -2968,15 +2779,17 @@ async def begin_delete_sql_trigger( :type trigger_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2993,24 +2806,14 @@ async def begin_delete_sql_trigger( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3022,8 +2825,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore + @distributed_trace_async async def get_sql_role_definition( self, role_definition_id: str, @@ -3049,28 +2854,18 @@ async def get_sql_role_definition( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_role_definition.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_role_definition_request( + role_definition_id=role_definition_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get_sql_role_definition.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3084,8 +2879,10 @@ async def get_sql_role_definition( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_role_definition.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore + async def _create_update_sql_role_definition_initial( self, role_definition_id: str, @@ -3099,33 +2896,23 @@ async def _create_update_sql_role_definition_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_role_definition_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_sql_role_definition_parameters, 'SqlRoleDefinitionCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_sql_role_definition_request_initial( + role_definition_id=role_definition_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_role_definition_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_role_definition_parameters, 'SqlRoleDefinitionCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3141,8 +2928,11 @@ async def _create_update_sql_role_definition_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_role_definition_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore + + @distributed_trace_async async def begin_create_update_sql_role_definition( self, role_definition_id: str, @@ -3161,18 +2951,24 @@ async def begin_create_update_sql_role_definition( :type account_name: str :param create_update_sql_role_definition_parameters: The properties required to create or update a Role Definition. - :type create_update_sql_role_definition_parameters: ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters + :type create_update_sql_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlRoleDefinitionGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -3185,28 +2981,21 @@ async def begin_create_update_sql_role_definition( resource_group_name=resource_group_name, account_name=account_name, create_update_sql_role_definition_parameters=create_update_sql_role_definition_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlRoleDefinitionGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3218,6 +3007,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_role_definition.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore async def _delete_sql_role_definition_initial( @@ -3232,28 +3022,18 @@ async def _delete_sql_role_definition_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_sql_role_definition_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_sql_role_definition_request_initial( + role_definition_id=role_definition_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self._delete_sql_role_definition_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3266,6 +3046,8 @@ async def _delete_sql_role_definition_initial( _delete_sql_role_definition_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore + + @distributed_trace_async async def begin_delete_sql_role_definition( self, role_definition_id: str, @@ -3283,15 +3065,17 @@ async def begin_delete_sql_role_definition( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3306,22 +3090,14 @@ async def begin_delete_sql_role_definition( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3333,8 +3109,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_role_definition.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore + @distributed_trace def list_sql_role_definitions( self, resource_group_name: str, @@ -3348,8 +3126,10 @@ def list_sql_role_definitions( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlRoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionListResult] + :return: An iterator like instance of either SqlRoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlRoleDefinitionListResult"] @@ -3357,36 +3137,33 @@ def list_sql_role_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_role_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_role_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_sql_role_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_role_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SqlRoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3404,11 +3181,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_sql_role_definitions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions'} # type: ignore + @distributed_trace_async async def get_sql_role_assignment( self, role_assignment_id: str, @@ -3434,28 +3213,18 @@ async def get_sql_role_assignment( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_role_assignment.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_role_assignment_request( + role_assignment_id=role_assignment_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get_sql_role_assignment.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3469,8 +3238,10 @@ async def get_sql_role_assignment( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_role_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore + async def _create_update_sql_role_assignment_initial( self, role_assignment_id: str, @@ -3484,33 +3255,23 @@ async def _create_update_sql_role_assignment_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_role_assignment_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_sql_role_assignment_parameters, 'SqlRoleAssignmentCreateUpdateParameters') + + request = build_create_update_sql_role_assignment_request_initial( + role_assignment_id=role_assignment_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_role_assignment_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_role_assignment_parameters, 'SqlRoleAssignmentCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3526,8 +3287,11 @@ async def _create_update_sql_role_assignment_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_role_assignment_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore + + @distributed_trace_async async def begin_create_update_sql_role_assignment( self, role_assignment_id: str, @@ -3546,18 +3310,24 @@ async def begin_create_update_sql_role_assignment( :type account_name: str :param create_update_sql_role_assignment_parameters: The properties required to create or update a Role Assignment. - :type create_update_sql_role_assignment_parameters: ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentCreateUpdateParameters + :type create_update_sql_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlRoleAssignmentGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlRoleAssignmentGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlRoleAssignmentGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -3570,28 +3340,21 @@ async def begin_create_update_sql_role_assignment( resource_group_name=resource_group_name, account_name=account_name, create_update_sql_role_assignment_parameters=create_update_sql_role_assignment_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlRoleAssignmentGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3603,6 +3366,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_role_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore async def _delete_sql_role_assignment_initial( @@ -3617,28 +3381,18 @@ async def _delete_sql_role_assignment_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_sql_role_assignment_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_sql_role_assignment_request_initial( + role_assignment_id=role_assignment_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self._delete_sql_role_assignment_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3651,6 +3405,8 @@ async def _delete_sql_role_assignment_initial( _delete_sql_role_assignment_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore + + @distributed_trace_async async def begin_delete_sql_role_assignment( self, role_assignment_id: str, @@ -3668,15 +3424,17 @@ async def begin_delete_sql_role_assignment( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3691,22 +3449,14 @@ async def begin_delete_sql_role_assignment( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3718,8 +3468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_role_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore + @distributed_trace def list_sql_role_assignments( self, resource_group_name: str, @@ -3733,8 +3485,10 @@ def list_sql_role_assignments( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlRoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentListResult] + :return: An iterator like instance of either SqlRoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlRoleAssignmentListResult"] @@ -3742,36 +3496,33 @@ def list_sql_role_assignments( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_role_assignments.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_role_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_sql_role_assignments.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_role_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SqlRoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3789,6 +3540,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -3808,34 +3560,24 @@ async def _retrieve_continuous_backup_information_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._retrieve_continuous_backup_information_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + + request = build_retrieve_continuous_backup_information_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + content_type=content_type, + json=_json, + template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(location, 'ContinuousBackupRestoreLocation') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3851,8 +3593,11 @@ async def _retrieve_continuous_backup_information_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _retrieve_continuous_backup_information_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation'} # type: ignore + + @distributed_trace_async async def begin_retrieve_continuous_backup_information( self, resource_group_name: str, @@ -3876,15 +3621,19 @@ async def begin_retrieve_continuous_backup_information( :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInformation"] lro_delay = kwargs.pop( 'polling_interval', @@ -3898,29 +3647,21 @@ async def begin_retrieve_continuous_backup_information( database_name=database_name, container_name=container_name, location=location, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BackupInformation', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3932,4 +3673,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_retrieve_continuous_backup_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_table_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_table_resources_operations.py index eac4de5eaba17..65792b0805639 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_table_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_table_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._table_resources_operations import build_create_update_table_request_initial, build_delete_table_request_initial, build_get_table_request, build_get_table_throughput_request, build_list_tables_request, build_migrate_table_to_autoscale_request_initial, build_migrate_table_to_manual_throughput_request_initial, build_update_table_throughput_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_tables( self, resource_group_name: str, @@ -65,36 +71,33 @@ def list_tables( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_tables.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_tables_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_tables.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_tables_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TableListResult', pipeline_response) + deserialized = self._deserialize("TableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,11 +115,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_tables.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables'} # type: ignore + @distributed_trace_async async def get_table( self, resource_group_name: str, @@ -142,28 +147,18 @@ async def get_table( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_table.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_table_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self.get_table.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,8 +172,10 @@ async def get_table( return cls(pipeline_response, deserialized, {}) return deserialized + get_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore + async def _create_update_table_initial( self, resource_group_name: str, @@ -192,33 +189,23 @@ async def _create_update_table_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_table_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_table_parameters, 'TableCreateUpdateParameters') + + request = build_create_update_table_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + content_type=content_type, + json=_json, + template_url=self._create_update_table_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_table_parameters, 'TableCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -234,8 +221,11 @@ async def _create_update_table_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_table_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore + + @distributed_trace_async async def begin_create_update_table( self, resource_group_name: str, @@ -256,15 +246,19 @@ async def begin_create_update_table( :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TableGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.TableGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -277,28 +271,21 @@ async def begin_create_update_table( account_name=account_name, table_name=table_name, create_update_table_parameters=create_update_table_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('TableGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -310,6 +297,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore async def _delete_table_initial( @@ -324,26 +312,18 @@ async def _delete_table_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_table_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_table_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self._delete_table_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -356,6 +336,8 @@ async def _delete_table_initial( _delete_table_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore + + @distributed_trace_async async def begin_delete_table( self, resource_group_name: str, @@ -373,15 +355,17 @@ async def begin_delete_table( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -396,22 +380,14 @@ async def begin_delete_table( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -423,8 +399,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore + @distributed_trace_async async def get_table_throughput( self, resource_group_name: str, @@ -451,28 +429,18 @@ async def get_table_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_table_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_table_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self.get_table_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -486,8 +454,10 @@ async def get_table_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default'} # type: ignore + async def _update_table_throughput_initial( self, resource_group_name: str, @@ -501,33 +471,23 @@ async def _update_table_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_table_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_table_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + content_type=content_type, + json=_json, + template_url=self._update_table_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -543,8 +503,11 @@ async def _update_table_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_table_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default'} # type: ignore + + @distributed_trace_async async def begin_update_table_throughput( self, resource_group_name: str, @@ -563,18 +526,24 @@ async def begin_update_table_throughput( :type table_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the current Table. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -587,28 +556,21 @@ async def begin_update_table_throughput( account_name=account_name, table_name=table_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -620,6 +582,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default'} # type: ignore async def _migrate_table_to_autoscale_initial( @@ -634,28 +597,18 @@ async def _migrate_table_to_autoscale_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_table_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_table_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self._migrate_table_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -671,8 +624,11 @@ async def _migrate_table_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_table_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace_async async def begin_migrate_table_to_autoscale( self, resource_group_name: str, @@ -690,15 +646,19 @@ async def begin_migrate_table_to_autoscale( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -713,25 +673,17 @@ async def begin_migrate_table_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -743,6 +695,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_table_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale'} # type: ignore async def _migrate_table_to_manual_throughput_initial( @@ -757,28 +710,18 @@ async def _migrate_table_to_manual_throughput_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_table_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_table_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self._migrate_table_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -794,8 +737,11 @@ async def _migrate_table_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_table_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace_async async def begin_migrate_table_to_manual_throughput( self, resource_group_name: str, @@ -813,15 +759,19 @@ async def begin_migrate_table_to_manual_throughput( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :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: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -836,25 +786,17 @@ async def begin_migrate_table_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -866,4 +808,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_table_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/__init__.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/__init__.py index f3bce9604251e..b26aba114b27a 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/__init__.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/__init__.py @@ -6,430 +6,218 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMProxyResource - from ._models_py3 import ARMResourceProperties - from ._models_py3 import AnalyticalStorageConfiguration - from ._models_py3 import ApiProperties - from ._models_py3 import AutoUpgradePolicyResource - from ._models_py3 import AutoscaleSettings - from ._models_py3 import AutoscaleSettingsResource - from ._models_py3 import BackupInformation - from ._models_py3 import BackupPolicy - from ._models_py3 import BackupPolicyMigrationState - from ._models_py3 import Capability - from ._models_py3 import Capacity - from ._models_py3 import CassandraClusterPublicStatus - from ._models_py3 import CassandraClusterPublicStatusDataCentersItem - from ._models_py3 import CassandraKeyspaceCreateUpdateParameters - from ._models_py3 import CassandraKeyspaceGetPropertiesOptions - from ._models_py3 import CassandraKeyspaceGetPropertiesResource - from ._models_py3 import CassandraKeyspaceGetResults - from ._models_py3 import CassandraKeyspaceListResult - from ._models_py3 import CassandraKeyspaceResource - from ._models_py3 import CassandraPartitionKey - from ._models_py3 import CassandraSchema - from ._models_py3 import CassandraTableCreateUpdateParameters - from ._models_py3 import CassandraTableGetPropertiesOptions - from ._models_py3 import CassandraTableGetPropertiesResource - from ._models_py3 import CassandraTableGetResults - from ._models_py3 import CassandraTableListResult - from ._models_py3 import CassandraTableResource - from ._models_py3 import Certificate - from ._models_py3 import ClusterKey - from ._models_py3 import ClusterResource - from ._models_py3 import ClusterResourceProperties - from ._models_py3 import Column - from ._models_py3 import CommandOutput - from ._models_py3 import CommandPostBody - from ._models_py3 import Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties - from ._models_py3 import ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems - from ._models_py3 import CompositePath - from ._models_py3 import ConflictResolutionPolicy - from ._models_py3 import ConnectionError - from ._models_py3 import ConsistencyPolicy - from ._models_py3 import ContainerPartitionKey - from ._models_py3 import ContinuousBackupInformation - from ._models_py3 import ContinuousBackupRestoreLocation - from ._models_py3 import ContinuousModeBackupPolicy - from ._models_py3 import CorsPolicy - from ._models_py3 import CreateUpdateOptions - from ._models_py3 import DataCenterResource - from ._models_py3 import DataCenterResourceProperties - from ._models_py3 import DatabaseAccountConnectionString - from ._models_py3 import DatabaseAccountCreateUpdateParameters - from ._models_py3 import DatabaseAccountGetResults - from ._models_py3 import DatabaseAccountListConnectionStringsResult - from ._models_py3 import DatabaseAccountListKeysResult - from ._models_py3 import DatabaseAccountListReadOnlyKeysResult - from ._models_py3 import DatabaseAccountRegenerateKeyParameters - from ._models_py3 import DatabaseAccountUpdateParameters - from ._models_py3 import DatabaseAccountsListResult - from ._models_py3 import DatabaseRestoreResource - from ._models_py3 import ErrorResponse - from ._models_py3 import ExcludedPath - from ._models_py3 import ExtendedResourceProperties - from ._models_py3 import FailoverPolicies - from ._models_py3 import FailoverPolicy - from ._models_py3 import GremlinDatabaseCreateUpdateParameters - from ._models_py3 import GremlinDatabaseGetPropertiesOptions - from ._models_py3 import GremlinDatabaseGetPropertiesResource - from ._models_py3 import GremlinDatabaseGetResults - from ._models_py3 import GremlinDatabaseListResult - from ._models_py3 import GremlinDatabaseResource - from ._models_py3 import GremlinGraphCreateUpdateParameters - from ._models_py3 import GremlinGraphGetPropertiesOptions - from ._models_py3 import GremlinGraphGetPropertiesResource - from ._models_py3 import GremlinGraphGetResults - from ._models_py3 import GremlinGraphListResult - from ._models_py3 import GremlinGraphResource - from ._models_py3 import IncludedPath - from ._models_py3 import Indexes - from ._models_py3 import IndexingPolicy - from ._models_py3 import IpAddressOrRange - from ._models_py3 import ListClusters - from ._models_py3 import ListDataCenters - from ._models_py3 import Location - from ._models_py3 import LocationGetResult - from ._models_py3 import LocationListResult - from ._models_py3 import LocationProperties - from ._models_py3 import ManagedCassandraARMResourceProperties - from ._models_py3 import ManagedCassandraManagedServiceIdentity - from ._models_py3 import ManagedCassandraReaperStatus - from ._models_py3 import ManagedServiceIdentity - from ._models_py3 import Metric - from ._models_py3 import MetricAvailability - from ._models_py3 import MetricDefinition - from ._models_py3 import MetricDefinitionsListResult - from ._models_py3 import MetricListResult - from ._models_py3 import MetricName - from ._models_py3 import MetricValue - from ._models_py3 import MongoDBCollectionCreateUpdateParameters - from ._models_py3 import MongoDBCollectionGetPropertiesOptions - from ._models_py3 import MongoDBCollectionGetPropertiesResource - from ._models_py3 import MongoDBCollectionGetResults - from ._models_py3 import MongoDBCollectionListResult - from ._models_py3 import MongoDBCollectionResource - from ._models_py3 import MongoDBDatabaseCreateUpdateParameters - from ._models_py3 import MongoDBDatabaseGetPropertiesOptions - from ._models_py3 import MongoDBDatabaseGetPropertiesResource - from ._models_py3 import MongoDBDatabaseGetResults - from ._models_py3 import MongoDBDatabaseListResult - from ._models_py3 import MongoDBDatabaseResource - from ._models_py3 import MongoIndex - from ._models_py3 import MongoIndexKeys - from ._models_py3 import MongoIndexOptions - from ._models_py3 import NotebookWorkspace - from ._models_py3 import NotebookWorkspaceConnectionInfoResult - from ._models_py3 import NotebookWorkspaceCreateUpdateParameters - from ._models_py3 import NotebookWorkspaceListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import OptionsResource - from ._models_py3 import PartitionMetric - from ._models_py3 import PartitionMetricListResult - from ._models_py3 import PartitionUsage - from ._models_py3 import PartitionUsagesResult - from ._models_py3 import PercentileMetric - from ._models_py3 import PercentileMetricListResult - from ._models_py3 import PercentileMetricValue - from ._models_py3 import PeriodicModeBackupPolicy - from ._models_py3 import PeriodicModeProperties - from ._models_py3 import Permission - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateEndpointProperty - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourceListResult - from ._models_py3 import PrivateLinkServiceConnectionStateProperty - from ._models_py3 import ProxyResource - from ._models_py3 import RegionForOnlineOffline - from ._models_py3 import Resource - from ._models_py3 import RestorableDatabaseAccountGetResult - from ._models_py3 import RestorableDatabaseAccountsListResult - from ._models_py3 import RestorableLocationResource - from ._models_py3 import RestorableMongodbCollectionGetResult - from ._models_py3 import RestorableMongodbCollectionPropertiesResource - from ._models_py3 import RestorableMongodbCollectionsListResult - from ._models_py3 import RestorableMongodbDatabaseGetResult - from ._models_py3 import RestorableMongodbDatabasePropertiesResource - from ._models_py3 import RestorableMongodbDatabasesListResult - from ._models_py3 import RestorableMongodbResourcesListResult - from ._models_py3 import RestorableSqlContainerGetResult - from ._models_py3 import RestorableSqlContainerPropertiesResource - from ._models_py3 import RestorableSqlContainerPropertiesResourceContainer - from ._models_py3 import RestorableSqlContainersListResult - from ._models_py3 import RestorableSqlDatabaseGetResult - from ._models_py3 import RestorableSqlDatabasePropertiesResource - from ._models_py3 import RestorableSqlDatabasePropertiesResourceDatabase - from ._models_py3 import RestorableSqlDatabasesListResult - from ._models_py3 import RestorableSqlResourcesListResult - from ._models_py3 import RestoreParameters - from ._models_py3 import SeedNode - from ._models_py3 import SpatialSpec - from ._models_py3 import SqlContainerCreateUpdateParameters - from ._models_py3 import SqlContainerGetPropertiesOptions - from ._models_py3 import SqlContainerGetPropertiesResource - from ._models_py3 import SqlContainerGetResults - from ._models_py3 import SqlContainerListResult - from ._models_py3 import SqlContainerResource - from ._models_py3 import SqlDatabaseCreateUpdateParameters - from ._models_py3 import SqlDatabaseGetPropertiesOptions - from ._models_py3 import SqlDatabaseGetPropertiesResource - from ._models_py3 import SqlDatabaseGetResults - from ._models_py3 import SqlDatabaseListResult - from ._models_py3 import SqlDatabaseResource - from ._models_py3 import SqlRoleAssignmentCreateUpdateParameters - from ._models_py3 import SqlRoleAssignmentGetResults - from ._models_py3 import SqlRoleAssignmentListResult - from ._models_py3 import SqlRoleDefinitionCreateUpdateParameters - from ._models_py3 import SqlRoleDefinitionGetResults - from ._models_py3 import SqlRoleDefinitionListResult - from ._models_py3 import SqlStoredProcedureCreateUpdateParameters - from ._models_py3 import SqlStoredProcedureGetPropertiesResource - from ._models_py3 import SqlStoredProcedureGetResults - from ._models_py3 import SqlStoredProcedureListResult - from ._models_py3 import SqlStoredProcedureResource - from ._models_py3 import SqlTriggerCreateUpdateParameters - from ._models_py3 import SqlTriggerGetPropertiesResource - from ._models_py3 import SqlTriggerGetResults - from ._models_py3 import SqlTriggerListResult - from ._models_py3 import SqlTriggerResource - from ._models_py3 import SqlUserDefinedFunctionCreateUpdateParameters - from ._models_py3 import SqlUserDefinedFunctionGetPropertiesResource - from ._models_py3 import SqlUserDefinedFunctionGetResults - from ._models_py3 import SqlUserDefinedFunctionListResult - from ._models_py3 import SqlUserDefinedFunctionResource - from ._models_py3 import SystemData - from ._models_py3 import TableCreateUpdateParameters - from ._models_py3 import TableGetPropertiesOptions - from ._models_py3 import TableGetPropertiesResource - from ._models_py3 import TableGetResults - from ._models_py3 import TableListResult - from ._models_py3 import TableResource - from ._models_py3 import ThroughputPolicyResource - from ._models_py3 import ThroughputSettingsGetPropertiesResource - from ._models_py3 import ThroughputSettingsGetResults - from ._models_py3 import ThroughputSettingsResource - from ._models_py3 import ThroughputSettingsUpdateParameters - from ._models_py3 import UniqueKey - from ._models_py3 import UniqueKeyPolicy - from ._models_py3 import Usage - from ._models_py3 import UsagesResult - from ._models_py3 import VirtualNetworkRule -except (SyntaxError, ImportError): - from ._models import ARMProxyResource # type: ignore - from ._models import ARMResourceProperties # type: ignore - from ._models import AnalyticalStorageConfiguration # type: ignore - from ._models import ApiProperties # type: ignore - from ._models import AutoUpgradePolicyResource # type: ignore - from ._models import AutoscaleSettings # type: ignore - from ._models import AutoscaleSettingsResource # type: ignore - from ._models import BackupInformation # type: ignore - from ._models import BackupPolicy # type: ignore - from ._models import BackupPolicyMigrationState # type: ignore - from ._models import Capability # type: ignore - from ._models import Capacity # type: ignore - from ._models import CassandraClusterPublicStatus # type: ignore - from ._models import CassandraClusterPublicStatusDataCentersItem # type: ignore - from ._models import CassandraKeyspaceCreateUpdateParameters # type: ignore - from ._models import CassandraKeyspaceGetPropertiesOptions # type: ignore - from ._models import CassandraKeyspaceGetPropertiesResource # type: ignore - from ._models import CassandraKeyspaceGetResults # type: ignore - from ._models import CassandraKeyspaceListResult # type: ignore - from ._models import CassandraKeyspaceResource # type: ignore - from ._models import CassandraPartitionKey # type: ignore - from ._models import CassandraSchema # type: ignore - from ._models import CassandraTableCreateUpdateParameters # type: ignore - from ._models import CassandraTableGetPropertiesOptions # type: ignore - from ._models import CassandraTableGetPropertiesResource # type: ignore - from ._models import CassandraTableGetResults # type: ignore - from ._models import CassandraTableListResult # type: ignore - from ._models import CassandraTableResource # type: ignore - from ._models import Certificate # type: ignore - from ._models import ClusterKey # type: ignore - from ._models import ClusterResource # type: ignore - from ._models import ClusterResourceProperties # type: ignore - from ._models import Column # type: ignore - from ._models import CommandOutput # type: ignore - from ._models import CommandPostBody # type: ignore - from ._models import Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties # type: ignore - from ._models import ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems # type: ignore - from ._models import CompositePath # type: ignore - from ._models import ConflictResolutionPolicy # type: ignore - from ._models import ConnectionError # type: ignore - from ._models import ConsistencyPolicy # type: ignore - from ._models import ContainerPartitionKey # type: ignore - from ._models import ContinuousBackupInformation # type: ignore - from ._models import ContinuousBackupRestoreLocation # type: ignore - from ._models import ContinuousModeBackupPolicy # type: ignore - from ._models import CorsPolicy # type: ignore - from ._models import CreateUpdateOptions # type: ignore - from ._models import DataCenterResource # type: ignore - from ._models import DataCenterResourceProperties # type: ignore - from ._models import DatabaseAccountConnectionString # type: ignore - from ._models import DatabaseAccountCreateUpdateParameters # type: ignore - from ._models import DatabaseAccountGetResults # type: ignore - from ._models import DatabaseAccountListConnectionStringsResult # type: ignore - from ._models import DatabaseAccountListKeysResult # type: ignore - from ._models import DatabaseAccountListReadOnlyKeysResult # type: ignore - from ._models import DatabaseAccountRegenerateKeyParameters # type: ignore - from ._models import DatabaseAccountUpdateParameters # type: ignore - from ._models import DatabaseAccountsListResult # type: ignore - from ._models import DatabaseRestoreResource # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ExcludedPath # type: ignore - from ._models import ExtendedResourceProperties # type: ignore - from ._models import FailoverPolicies # type: ignore - from ._models import FailoverPolicy # type: ignore - from ._models import GremlinDatabaseCreateUpdateParameters # type: ignore - from ._models import GremlinDatabaseGetPropertiesOptions # type: ignore - from ._models import GremlinDatabaseGetPropertiesResource # type: ignore - from ._models import GremlinDatabaseGetResults # type: ignore - from ._models import GremlinDatabaseListResult # type: ignore - from ._models import GremlinDatabaseResource # type: ignore - from ._models import GremlinGraphCreateUpdateParameters # type: ignore - from ._models import GremlinGraphGetPropertiesOptions # type: ignore - from ._models import GremlinGraphGetPropertiesResource # type: ignore - from ._models import GremlinGraphGetResults # type: ignore - from ._models import GremlinGraphListResult # type: ignore - from ._models import GremlinGraphResource # type: ignore - from ._models import IncludedPath # type: ignore - from ._models import Indexes # type: ignore - from ._models import IndexingPolicy # type: ignore - from ._models import IpAddressOrRange # type: ignore - from ._models import ListClusters # type: ignore - from ._models import ListDataCenters # type: ignore - from ._models import Location # type: ignore - from ._models import LocationGetResult # type: ignore - from ._models import LocationListResult # type: ignore - from ._models import LocationProperties # type: ignore - from ._models import ManagedCassandraARMResourceProperties # type: ignore - from ._models import ManagedCassandraManagedServiceIdentity # type: ignore - from ._models import ManagedCassandraReaperStatus # type: ignore - from ._models import ManagedServiceIdentity # type: ignore - from ._models import Metric # type: ignore - from ._models import MetricAvailability # type: ignore - from ._models import MetricDefinition # type: ignore - from ._models import MetricDefinitionsListResult # type: ignore - from ._models import MetricListResult # type: ignore - from ._models import MetricName # type: ignore - from ._models import MetricValue # type: ignore - from ._models import MongoDBCollectionCreateUpdateParameters # type: ignore - from ._models import MongoDBCollectionGetPropertiesOptions # type: ignore - from ._models import MongoDBCollectionGetPropertiesResource # type: ignore - from ._models import MongoDBCollectionGetResults # type: ignore - from ._models import MongoDBCollectionListResult # type: ignore - from ._models import MongoDBCollectionResource # type: ignore - from ._models import MongoDBDatabaseCreateUpdateParameters # type: ignore - from ._models import MongoDBDatabaseGetPropertiesOptions # type: ignore - from ._models import MongoDBDatabaseGetPropertiesResource # type: ignore - from ._models import MongoDBDatabaseGetResults # type: ignore - from ._models import MongoDBDatabaseListResult # type: ignore - from ._models import MongoDBDatabaseResource # type: ignore - from ._models import MongoIndex # type: ignore - from ._models import MongoIndexKeys # type: ignore - from ._models import MongoIndexOptions # type: ignore - from ._models import NotebookWorkspace # type: ignore - from ._models import NotebookWorkspaceConnectionInfoResult # type: ignore - from ._models import NotebookWorkspaceCreateUpdateParameters # type: ignore - from ._models import NotebookWorkspaceListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import OptionsResource # type: ignore - from ._models import PartitionMetric # type: ignore - from ._models import PartitionMetricListResult # type: ignore - from ._models import PartitionUsage # type: ignore - from ._models import PartitionUsagesResult # type: ignore - from ._models import PercentileMetric # type: ignore - from ._models import PercentileMetricListResult # type: ignore - from ._models import PercentileMetricValue # type: ignore - from ._models import PeriodicModeBackupPolicy # type: ignore - from ._models import PeriodicModeProperties # type: ignore - from ._models import Permission # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateEndpointProperty # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourceListResult # type: ignore - from ._models import PrivateLinkServiceConnectionStateProperty # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import RegionForOnlineOffline # type: ignore - from ._models import Resource # type: ignore - from ._models import RestorableDatabaseAccountGetResult # type: ignore - from ._models import RestorableDatabaseAccountsListResult # type: ignore - from ._models import RestorableLocationResource # type: ignore - from ._models import RestorableMongodbCollectionGetResult # type: ignore - from ._models import RestorableMongodbCollectionPropertiesResource # type: ignore - from ._models import RestorableMongodbCollectionsListResult # type: ignore - from ._models import RestorableMongodbDatabaseGetResult # type: ignore - from ._models import RestorableMongodbDatabasePropertiesResource # type: ignore - from ._models import RestorableMongodbDatabasesListResult # type: ignore - from ._models import RestorableMongodbResourcesListResult # type: ignore - from ._models import RestorableSqlContainerGetResult # type: ignore - from ._models import RestorableSqlContainerPropertiesResource # type: ignore - from ._models import RestorableSqlContainerPropertiesResourceContainer # type: ignore - from ._models import RestorableSqlContainersListResult # type: ignore - from ._models import RestorableSqlDatabaseGetResult # type: ignore - from ._models import RestorableSqlDatabasePropertiesResource # type: ignore - from ._models import RestorableSqlDatabasePropertiesResourceDatabase # type: ignore - from ._models import RestorableSqlDatabasesListResult # type: ignore - from ._models import RestorableSqlResourcesListResult # type: ignore - from ._models import RestoreParameters # type: ignore - from ._models import SeedNode # type: ignore - from ._models import SpatialSpec # type: ignore - from ._models import SqlContainerCreateUpdateParameters # type: ignore - from ._models import SqlContainerGetPropertiesOptions # type: ignore - from ._models import SqlContainerGetPropertiesResource # type: ignore - from ._models import SqlContainerGetResults # type: ignore - from ._models import SqlContainerListResult # type: ignore - from ._models import SqlContainerResource # type: ignore - from ._models import SqlDatabaseCreateUpdateParameters # type: ignore - from ._models import SqlDatabaseGetPropertiesOptions # type: ignore - from ._models import SqlDatabaseGetPropertiesResource # type: ignore - from ._models import SqlDatabaseGetResults # type: ignore - from ._models import SqlDatabaseListResult # type: ignore - from ._models import SqlDatabaseResource # type: ignore - from ._models import SqlRoleAssignmentCreateUpdateParameters # type: ignore - from ._models import SqlRoleAssignmentGetResults # type: ignore - from ._models import SqlRoleAssignmentListResult # type: ignore - from ._models import SqlRoleDefinitionCreateUpdateParameters # type: ignore - from ._models import SqlRoleDefinitionGetResults # type: ignore - from ._models import SqlRoleDefinitionListResult # type: ignore - from ._models import SqlStoredProcedureCreateUpdateParameters # type: ignore - from ._models import SqlStoredProcedureGetPropertiesResource # type: ignore - from ._models import SqlStoredProcedureGetResults # type: ignore - from ._models import SqlStoredProcedureListResult # type: ignore - from ._models import SqlStoredProcedureResource # type: ignore - from ._models import SqlTriggerCreateUpdateParameters # type: ignore - from ._models import SqlTriggerGetPropertiesResource # type: ignore - from ._models import SqlTriggerGetResults # type: ignore - from ._models import SqlTriggerListResult # type: ignore - from ._models import SqlTriggerResource # type: ignore - from ._models import SqlUserDefinedFunctionCreateUpdateParameters # type: ignore - from ._models import SqlUserDefinedFunctionGetPropertiesResource # type: ignore - from ._models import SqlUserDefinedFunctionGetResults # type: ignore - from ._models import SqlUserDefinedFunctionListResult # type: ignore - from ._models import SqlUserDefinedFunctionResource # type: ignore - from ._models import SystemData # type: ignore - from ._models import TableCreateUpdateParameters # type: ignore - from ._models import TableGetPropertiesOptions # type: ignore - from ._models import TableGetPropertiesResource # type: ignore - from ._models import TableGetResults # type: ignore - from ._models import TableListResult # type: ignore - from ._models import TableResource # type: ignore - from ._models import ThroughputPolicyResource # type: ignore - from ._models import ThroughputSettingsGetPropertiesResource # type: ignore - from ._models import ThroughputSettingsGetResults # type: ignore - from ._models import ThroughputSettingsResource # type: ignore - from ._models import ThroughputSettingsUpdateParameters # type: ignore - from ._models import UniqueKey # type: ignore - from ._models import UniqueKeyPolicy # type: ignore - from ._models import Usage # type: ignore - from ._models import UsagesResult # type: ignore - from ._models import VirtualNetworkRule # type: ignore +from ._models_py3 import ARMProxyResource +from ._models_py3 import ARMResourceProperties +from ._models_py3 import AnalyticalStorageConfiguration +from ._models_py3 import ApiProperties +from ._models_py3 import AutoUpgradePolicyResource +from ._models_py3 import AutoscaleSettings +from ._models_py3 import AutoscaleSettingsResource +from ._models_py3 import BackupInformation +from ._models_py3 import BackupPolicy +from ._models_py3 import BackupPolicyMigrationState +from ._models_py3 import Capability +from ._models_py3 import Capacity +from ._models_py3 import CassandraClusterPublicStatus +from ._models_py3 import CassandraClusterPublicStatusDataCentersItem +from ._models_py3 import CassandraKeyspaceCreateUpdateParameters +from ._models_py3 import CassandraKeyspaceGetPropertiesOptions +from ._models_py3 import CassandraKeyspaceGetPropertiesResource +from ._models_py3 import CassandraKeyspaceGetResults +from ._models_py3 import CassandraKeyspaceListResult +from ._models_py3 import CassandraKeyspaceResource +from ._models_py3 import CassandraPartitionKey +from ._models_py3 import CassandraSchema +from ._models_py3 import CassandraTableCreateUpdateParameters +from ._models_py3 import CassandraTableGetPropertiesOptions +from ._models_py3 import CassandraTableGetPropertiesResource +from ._models_py3 import CassandraTableGetResults +from ._models_py3 import CassandraTableListResult +from ._models_py3 import CassandraTableResource +from ._models_py3 import Certificate +from ._models_py3 import ClusterKey +from ._models_py3 import ClusterResource +from ._models_py3 import ClusterResourceProperties +from ._models_py3 import Column +from ._models_py3 import CommandOutput +from ._models_py3 import CommandPostBody +from ._models_py3 import Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties +from ._models_py3 import ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems +from ._models_py3 import CompositePath +from ._models_py3 import ConflictResolutionPolicy +from ._models_py3 import ConnectionError +from ._models_py3 import ConsistencyPolicy +from ._models_py3 import ContainerPartitionKey +from ._models_py3 import ContinuousBackupInformation +from ._models_py3 import ContinuousBackupRestoreLocation +from ._models_py3 import ContinuousModeBackupPolicy +from ._models_py3 import CorsPolicy +from ._models_py3 import CreateUpdateOptions +from ._models_py3 import DataCenterResource +from ._models_py3 import DataCenterResourceProperties +from ._models_py3 import DatabaseAccountConnectionString +from ._models_py3 import DatabaseAccountCreateUpdateParameters +from ._models_py3 import DatabaseAccountGetResults +from ._models_py3 import DatabaseAccountListConnectionStringsResult +from ._models_py3 import DatabaseAccountListKeysResult +from ._models_py3 import DatabaseAccountListReadOnlyKeysResult +from ._models_py3 import DatabaseAccountRegenerateKeyParameters +from ._models_py3 import DatabaseAccountUpdateParameters +from ._models_py3 import DatabaseAccountsListResult +from ._models_py3 import DatabaseRestoreResource +from ._models_py3 import ErrorResponse +from ._models_py3 import ExcludedPath +from ._models_py3 import ExtendedResourceProperties +from ._models_py3 import FailoverPolicies +from ._models_py3 import FailoverPolicy +from ._models_py3 import GremlinDatabaseCreateUpdateParameters +from ._models_py3 import GremlinDatabaseGetPropertiesOptions +from ._models_py3 import GremlinDatabaseGetPropertiesResource +from ._models_py3 import GremlinDatabaseGetResults +from ._models_py3 import GremlinDatabaseListResult +from ._models_py3 import GremlinDatabaseResource +from ._models_py3 import GremlinGraphCreateUpdateParameters +from ._models_py3 import GremlinGraphGetPropertiesOptions +from ._models_py3 import GremlinGraphGetPropertiesResource +from ._models_py3 import GremlinGraphGetResults +from ._models_py3 import GremlinGraphListResult +from ._models_py3 import GremlinGraphResource +from ._models_py3 import IncludedPath +from ._models_py3 import Indexes +from ._models_py3 import IndexingPolicy +from ._models_py3 import IpAddressOrRange +from ._models_py3 import ListClusters +from ._models_py3 import ListDataCenters +from ._models_py3 import Location +from ._models_py3 import LocationGetResult +from ._models_py3 import LocationListResult +from ._models_py3 import LocationProperties +from ._models_py3 import ManagedCassandraARMResourceProperties +from ._models_py3 import ManagedCassandraManagedServiceIdentity +from ._models_py3 import ManagedCassandraReaperStatus +from ._models_py3 import ManagedServiceIdentity +from ._models_py3 import Metric +from ._models_py3 import MetricAvailability +from ._models_py3 import MetricDefinition +from ._models_py3 import MetricDefinitionsListResult +from ._models_py3 import MetricListResult +from ._models_py3 import MetricName +from ._models_py3 import MetricValue +from ._models_py3 import MongoDBCollectionCreateUpdateParameters +from ._models_py3 import MongoDBCollectionGetPropertiesOptions +from ._models_py3 import MongoDBCollectionGetPropertiesResource +from ._models_py3 import MongoDBCollectionGetResults +from ._models_py3 import MongoDBCollectionListResult +from ._models_py3 import MongoDBCollectionResource +from ._models_py3 import MongoDBDatabaseCreateUpdateParameters +from ._models_py3 import MongoDBDatabaseGetPropertiesOptions +from ._models_py3 import MongoDBDatabaseGetPropertiesResource +from ._models_py3 import MongoDBDatabaseGetResults +from ._models_py3 import MongoDBDatabaseListResult +from ._models_py3 import MongoDBDatabaseResource +from ._models_py3 import MongoIndex +from ._models_py3 import MongoIndexKeys +from ._models_py3 import MongoIndexOptions +from ._models_py3 import NotebookWorkspace +from ._models_py3 import NotebookWorkspaceConnectionInfoResult +from ._models_py3 import NotebookWorkspaceCreateUpdateParameters +from ._models_py3 import NotebookWorkspaceListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OptionsResource +from ._models_py3 import PartitionMetric +from ._models_py3 import PartitionMetricListResult +from ._models_py3 import PartitionUsage +from ._models_py3 import PartitionUsagesResult +from ._models_py3 import PercentileMetric +from ._models_py3 import PercentileMetricListResult +from ._models_py3 import PercentileMetricValue +from ._models_py3 import PeriodicModeBackupPolicy +from ._models_py3 import PeriodicModeProperties +from ._models_py3 import Permission +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateEndpointProperty +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionStateProperty +from ._models_py3 import ProxyResource +from ._models_py3 import RegionForOnlineOffline +from ._models_py3 import Resource +from ._models_py3 import RestorableDatabaseAccountGetResult +from ._models_py3 import RestorableDatabaseAccountsListResult +from ._models_py3 import RestorableLocationResource +from ._models_py3 import RestorableMongodbCollectionGetResult +from ._models_py3 import RestorableMongodbCollectionPropertiesResource +from ._models_py3 import RestorableMongodbCollectionsListResult +from ._models_py3 import RestorableMongodbDatabaseGetResult +from ._models_py3 import RestorableMongodbDatabasePropertiesResource +from ._models_py3 import RestorableMongodbDatabasesListResult +from ._models_py3 import RestorableMongodbResourcesListResult +from ._models_py3 import RestorableSqlContainerGetResult +from ._models_py3 import RestorableSqlContainerPropertiesResource +from ._models_py3 import RestorableSqlContainerPropertiesResourceContainer +from ._models_py3 import RestorableSqlContainersListResult +from ._models_py3 import RestorableSqlDatabaseGetResult +from ._models_py3 import RestorableSqlDatabasePropertiesResource +from ._models_py3 import RestorableSqlDatabasePropertiesResourceDatabase +from ._models_py3 import RestorableSqlDatabasesListResult +from ._models_py3 import RestorableSqlResourcesListResult +from ._models_py3 import RestoreParameters +from ._models_py3 import SeedNode +from ._models_py3 import SpatialSpec +from ._models_py3 import SqlContainerCreateUpdateParameters +from ._models_py3 import SqlContainerGetPropertiesOptions +from ._models_py3 import SqlContainerGetPropertiesResource +from ._models_py3 import SqlContainerGetResults +from ._models_py3 import SqlContainerListResult +from ._models_py3 import SqlContainerResource +from ._models_py3 import SqlDatabaseCreateUpdateParameters +from ._models_py3 import SqlDatabaseGetPropertiesOptions +from ._models_py3 import SqlDatabaseGetPropertiesResource +from ._models_py3 import SqlDatabaseGetResults +from ._models_py3 import SqlDatabaseListResult +from ._models_py3 import SqlDatabaseResource +from ._models_py3 import SqlRoleAssignmentCreateUpdateParameters +from ._models_py3 import SqlRoleAssignmentGetResults +from ._models_py3 import SqlRoleAssignmentListResult +from ._models_py3 import SqlRoleDefinitionCreateUpdateParameters +from ._models_py3 import SqlRoleDefinitionGetResults +from ._models_py3 import SqlRoleDefinitionListResult +from ._models_py3 import SqlStoredProcedureCreateUpdateParameters +from ._models_py3 import SqlStoredProcedureGetPropertiesResource +from ._models_py3 import SqlStoredProcedureGetResults +from ._models_py3 import SqlStoredProcedureListResult +from ._models_py3 import SqlStoredProcedureResource +from ._models_py3 import SqlTriggerCreateUpdateParameters +from ._models_py3 import SqlTriggerGetPropertiesResource +from ._models_py3 import SqlTriggerGetResults +from ._models_py3 import SqlTriggerListResult +from ._models_py3 import SqlTriggerResource +from ._models_py3 import SqlUserDefinedFunctionCreateUpdateParameters +from ._models_py3 import SqlUserDefinedFunctionGetPropertiesResource +from ._models_py3 import SqlUserDefinedFunctionGetResults +from ._models_py3 import SqlUserDefinedFunctionListResult +from ._models_py3 import SqlUserDefinedFunctionResource +from ._models_py3 import SystemData +from ._models_py3 import TableCreateUpdateParameters +from ._models_py3 import TableGetPropertiesOptions +from ._models_py3 import TableGetPropertiesResource +from ._models_py3 import TableGetResults +from ._models_py3 import TableListResult +from ._models_py3 import TableResource +from ._models_py3 import ThroughputPolicyResource +from ._models_py3 import ThroughputSettingsGetPropertiesResource +from ._models_py3 import ThroughputSettingsGetResults +from ._models_py3 import ThroughputSettingsResource +from ._models_py3 import ThroughputSettingsUpdateParameters +from ._models_py3 import UniqueKey +from ._models_py3 import UniqueKeyPolicy +from ._models_py3 import Usage +from ._models_py3 import UsagesResult +from ._models_py3 import VirtualNetworkRule + from ._cosmos_db_management_client_enums import ( AnalyticalStorageSchemaType, diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_cosmos_db_management_client_enums.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_cosmos_db_management_client_enums.py index f76cd8dabee43..256a05b535d16 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_cosmos_db_management_client_enums.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_cosmos_db_management_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AnalyticalStorageSchemaType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AnalyticalStorageSchemaType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes the types of schema for analytical storage. """ WELL_DEFINED = "WellDefined" FULL_FIDELITY = "FullFidelity" -class ApiType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enum to indicate the API type of the restorable database account. """ @@ -44,7 +29,7 @@ class ApiType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SQL = "Sql" GREMLIN_V2 = "GremlinV2" -class AuthenticationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AuthenticationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Which authentication method Cassandra should use to authenticate clients. 'None' turns off authentication, so should not be used except in emergencies. 'Cassandra' is the default password based authentication. The default is 'Cassandra'. @@ -53,7 +38,7 @@ class AuthenticationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NONE = "None" CASSANDRA = "Cassandra" -class BackupPolicyMigrationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BackupPolicyMigrationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes the status of migration between backup policy types. """ @@ -62,14 +47,14 @@ class BackupPolicyMigrationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, COMPLETED = "Completed" FAILED = "Failed" -class BackupPolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BackupPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes the mode of backups. """ PERIODIC = "Periodic" CONTINUOUS = "Continuous" -class BackupStorageRedundancy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BackupStorageRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enum to indicate type of backup storage redundancy. """ @@ -77,21 +62,21 @@ class BackupStorageRedundancy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum LOCAL = "Local" ZONE = "Zone" -class CompositePathSortOrder(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CompositePathSortOrder(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sort order for composite paths. """ ASCENDING = "ascending" DESCENDING = "descending" -class ConflictResolutionMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConflictResolutionMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the conflict resolution mode. """ LAST_WRITER_WINS = "LastWriterWins" CUSTOM = "Custom" -class ConnectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConnectionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of connection error that occurred. """ @@ -102,13 +87,13 @@ class ConnectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INTERNAL_OPERATOR_TO_DATA_CENTER_CERTIFICATE_ERROR = "InternalOperatorToDataCenterCertificateError" INTERNAL_ERROR = "InternalError" -class ConnectorOffer(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConnectorOffer(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The cassandra connector offer type for the Cosmos DB C* database account. """ SMALL = "Small" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -117,14 +102,14 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class CreateMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreateMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enum to indicate the mode of account creation. """ DEFAULT = "Default" RESTORE = "Restore" -class DatabaseAccountKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DatabaseAccountKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the type of database account. This can only be set at database account creation. """ @@ -132,7 +117,7 @@ class DatabaseAccountKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MONGO_DB = "MongoDB" PARSE = "Parse" -class DataType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DataType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The datatype for which the indexing behavior is applied to. """ @@ -143,7 +128,7 @@ class DataType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LINE_STRING = "LineString" MULTI_POLYGON = "MultiPolygon" -class DefaultConsistencyLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultConsistencyLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The default consistency level and configuration settings of the Cosmos DB account. """ @@ -153,7 +138,7 @@ class DefaultConsistencyLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum STRONG = "Strong" CONSISTENT_PREFIX = "ConsistentPrefix" -class IndexingMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IndexingMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the indexing mode. """ @@ -161,7 +146,7 @@ class IndexingMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LAZY = "lazy" NONE = "none" -class IndexKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IndexKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the type of index. """ @@ -169,7 +154,7 @@ class IndexKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RANGE = "Range" SPATIAL = "Spatial" -class KeyKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KeyKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The access key to regenerate. """ @@ -178,7 +163,7 @@ class KeyKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PRIMARY_READONLY = "primaryReadonly" SECONDARY_READONLY = "secondaryReadonly" -class ManagedCassandraProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedCassandraProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the resource at the time the operation was called. """ @@ -189,21 +174,21 @@ class ManagedCassandraProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, FAILED = "Failed" CANCELED = "Canceled" -class ManagedCassandraResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedCassandraResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the resource. """ SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" -class NetworkAclBypass(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAclBypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates what services are allowed to bypass firewall checks. """ NONE = "None" AZURE_SERVICES = "AzureServices" -class NodeState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NodeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the node in Cassandra ring. """ @@ -213,18 +198,18 @@ class NodeState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MOVING = "Moving" STOPPED = "Stopped" -class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NodeStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates whether the node is functioning or not. """ UP = "Up" DOWN = "Down" -class NotebookWorkspaceName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NotebookWorkspaceName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "default" -class OperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enum to indicate the operation type of the event. """ @@ -233,7 +218,7 @@ class OperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETE = "Delete" SYSTEM_OPERATION = "SystemOperation" -class PartitionKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PartitionKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the kind of algorithm used for partitioning. For MultiHash, multiple partition keys (upto three maximum) are supported for container create """ @@ -242,7 +227,7 @@ class PartitionKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RANGE = "Range" MULTI_HASH = "MultiHash" -class PrimaryAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrimaryAggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The primary aggregation type of the metric. """ @@ -253,14 +238,14 @@ class PrimaryAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) MAXIMUM = "Maximum" LAST = "Last" -class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether requests from Public Network are allowed """ ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. @@ -271,20 +256,20 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" NONE = "None" -class RestoreMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RestoreMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes the mode of the restore. """ POINT_IN_TIME = "PointInTime" -class RoleDefinitionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleDefinitionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates whether the Role Definition was built-in or user created. """ BUILT_IN_ROLE = "BuiltInRole" CUSTOM_ROLE = "CustomRole" -class ServerVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes the ServerVersion of an a MongoDB account. """ @@ -292,7 +277,7 @@ class ServerVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): THREE6 = "3.6" FOUR0 = "4.0" -class SpatialType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SpatialType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the spatial type of index. """ @@ -301,7 +286,7 @@ class SpatialType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): POLYGON = "Polygon" MULTI_POLYGON = "MultiPolygon" -class TriggerOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TriggerOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operation the trigger is associated with """ @@ -311,14 +296,14 @@ class TriggerOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETE = "Delete" REPLACE = "Replace" -class TriggerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the Trigger """ PRE = "Pre" POST = "Post" -class UnitType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnitType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_models_py3.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_models_py3.py index 05f6ce9d66e40..ae91c860d3cd2 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_models_py3.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_models_py3.py @@ -18,9 +18,9 @@ class AnalyticalStorageConfiguration(msrest.serialization.Model): """Analytical storage specific properties. - :param schema_type: Describes the types of schema for analytical storage. Possible values + :ivar schema_type: Describes the types of schema for analytical storage. Possible values include: "WellDefined", "FullFidelity". - :type schema_type: str or ~azure.mgmt.cosmosdb.models.AnalyticalStorageSchemaType + :vartype schema_type: str or ~azure.mgmt.cosmosdb.models.AnalyticalStorageSchemaType """ _attribute_map = { @@ -33,6 +33,11 @@ def __init__( schema_type: Optional[Union[str, "AnalyticalStorageSchemaType"]] = None, **kwargs ): + """ + :keyword schema_type: Describes the types of schema for analytical storage. Possible values + include: "WellDefined", "FullFidelity". + :paramtype schema_type: str or ~azure.mgmt.cosmosdb.models.AnalyticalStorageSchemaType + """ super(AnalyticalStorageConfiguration, self).__init__(**kwargs) self.schema_type = schema_type @@ -40,9 +45,9 @@ def __init__( class ApiProperties(msrest.serialization.Model): """ApiProperties. - :param server_version: Describes the ServerVersion of an a MongoDB account. Possible values + :ivar server_version: Describes the ServerVersion of an a MongoDB account. Possible values include: "3.2", "3.6", "4.0". - :type server_version: str or ~azure.mgmt.cosmosdb.models.ServerVersion + :vartype server_version: str or ~azure.mgmt.cosmosdb.models.ServerVersion """ _attribute_map = { @@ -55,6 +60,11 @@ def __init__( server_version: Optional[Union[str, "ServerVersion"]] = None, **kwargs ): + """ + :keyword server_version: Describes the ServerVersion of an a MongoDB account. Possible values + include: "3.2", "3.6", "4.0". + :paramtype server_version: str or ~azure.mgmt.cosmosdb.models.ServerVersion + """ super(ApiProperties, self).__init__(**kwargs) self.server_version = server_version @@ -88,6 +98,8 @@ def __init__( self, **kwargs ): + """ + """ super(ARMProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -105,15 +117,15 @@ class ARMResourceProperties(msrest.serialization.Model): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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] """ _validation = { @@ -137,6 +149,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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] + """ super(ARMResourceProperties, self).__init__(**kwargs) self.id = None self.name = None @@ -148,8 +171,8 @@ def __init__( class AutoscaleSettings(msrest.serialization.Model): """AutoscaleSettings. - :param max_throughput: Represents maximum throughput, the resource can scale up to. - :type max_throughput: int + :ivar max_throughput: Represents maximum throughput, the resource can scale up to. + :vartype max_throughput: int """ _attribute_map = { @@ -162,6 +185,10 @@ def __init__( max_throughput: Optional[int] = None, **kwargs ): + """ + :keyword max_throughput: Represents maximum throughput, the resource can scale up to. + :paramtype max_throughput: int + """ super(AutoscaleSettings, self).__init__(**kwargs) self.max_throughput = max_throughput @@ -173,10 +200,10 @@ class AutoscaleSettingsResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param max_throughput: Required. Represents maximum throughput container can scale up to. - :type max_throughput: int - :param auto_upgrade_policy: Cosmos DB resource auto-upgrade policy. - :type auto_upgrade_policy: ~azure.mgmt.cosmosdb.models.AutoUpgradePolicyResource + :ivar max_throughput: Required. Represents maximum throughput container can scale up to. + :vartype max_throughput: int + :ivar auto_upgrade_policy: Cosmos DB resource auto-upgrade policy. + :vartype auto_upgrade_policy: ~azure.mgmt.cosmosdb.models.AutoUpgradePolicyResource :ivar target_max_throughput: Represents target maximum throughput container can scale up to once offer is no longer in pending state. :vartype target_max_throughput: int @@ -200,6 +227,12 @@ def __init__( auto_upgrade_policy: Optional["AutoUpgradePolicyResource"] = None, **kwargs ): + """ + :keyword max_throughput: Required. Represents maximum throughput container can scale up to. + :paramtype max_throughput: int + :keyword auto_upgrade_policy: Cosmos DB resource auto-upgrade policy. + :paramtype auto_upgrade_policy: ~azure.mgmt.cosmosdb.models.AutoUpgradePolicyResource + """ super(AutoscaleSettingsResource, self).__init__(**kwargs) self.max_throughput = max_throughput self.auto_upgrade_policy = auto_upgrade_policy @@ -209,9 +242,9 @@ def __init__( class AutoUpgradePolicyResource(msrest.serialization.Model): """Cosmos DB resource auto-upgrade policy. - :param throughput_policy: Represents throughput policy which service must adhere to for + :ivar throughput_policy: Represents throughput policy which service must adhere to for auto-upgrade. - :type throughput_policy: ~azure.mgmt.cosmosdb.models.ThroughputPolicyResource + :vartype throughput_policy: ~azure.mgmt.cosmosdb.models.ThroughputPolicyResource """ _attribute_map = { @@ -224,6 +257,11 @@ def __init__( throughput_policy: Optional["ThroughputPolicyResource"] = None, **kwargs ): + """ + :keyword throughput_policy: Represents throughput policy which service must adhere to for + auto-upgrade. + :paramtype throughput_policy: ~azure.mgmt.cosmosdb.models.ThroughputPolicyResource + """ super(AutoUpgradePolicyResource, self).__init__(**kwargs) self.throughput_policy = throughput_policy @@ -249,6 +287,8 @@ def __init__( self, **kwargs ): + """ + """ super(BackupInformation, self).__init__(**kwargs) self.continuous_backup_information = None @@ -261,12 +301,12 @@ class BackupPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. Describes the mode of backups.Constant filled by server. Possible - values include: "Periodic", "Continuous". - :type type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType - :param migration_state: The object representing the state of the migration between the backup + :ivar type: Required. Describes the mode of backups.Constant filled by server. Possible values + include: "Periodic", "Continuous". + :vartype type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType + :ivar migration_state: The object representing the state of the migration between the backup policies. - :type migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState + :vartype migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState """ _validation = { @@ -288,6 +328,11 @@ def __init__( migration_state: Optional["BackupPolicyMigrationState"] = None, **kwargs ): + """ + :keyword migration_state: The object representing the state of the migration between the backup + policies. + :paramtype migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState + """ super(BackupPolicy, self).__init__(**kwargs) self.type = None # type: Optional[str] self.migration_state = migration_state @@ -296,14 +341,14 @@ def __init__( class BackupPolicyMigrationState(msrest.serialization.Model): """The object representing the state of the migration between the backup policies. - :param status: Describes the status of migration between backup policy types. Possible values + :ivar status: Describes the status of migration between backup policy types. Possible values include: "Invalid", "InProgress", "Completed", "Failed". - :type status: str or ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationStatus - :param target_type: Describes the target backup policy type of the backup policy migration. + :vartype status: str or ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationStatus + :ivar target_type: Describes the target backup policy type of the backup policy migration. Possible values include: "Periodic", "Continuous". - :type target_type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType - :param start_time: Time at which the backup policy migration started (ISO-8601 format). - :type start_time: ~datetime.datetime + :vartype target_type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType + :ivar start_time: Time at which the backup policy migration started (ISO-8601 format). + :vartype start_time: ~datetime.datetime """ _attribute_map = { @@ -320,6 +365,16 @@ def __init__( start_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword status: Describes the status of migration between backup policy types. Possible values + include: "Invalid", "InProgress", "Completed", "Failed". + :paramtype status: str or ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationStatus + :keyword target_type: Describes the target backup policy type of the backup policy migration. + Possible values include: "Periodic", "Continuous". + :paramtype target_type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType + :keyword start_time: Time at which the backup policy migration started (ISO-8601 format). + :paramtype start_time: ~datetime.datetime + """ super(BackupPolicyMigrationState, self).__init__(**kwargs) self.status = status self.target_type = target_type @@ -329,9 +384,9 @@ def __init__( class Capability(msrest.serialization.Model): """Cosmos DB capability object. - :param name: Name of the Cosmos DB capability. For example, "name": "EnableCassandra". Current + :ivar name: Name of the Cosmos DB capability. For example, "name": "EnableCassandra". Current values also include "EnableTable" and "EnableGremlin". - :type name: str + :vartype name: str """ _attribute_map = { @@ -344,6 +399,11 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the Cosmos DB capability. For example, "name": "EnableCassandra". + Current values also include "EnableTable" and "EnableGremlin". + :paramtype name: str + """ super(Capability, self).__init__(**kwargs) self.name = name @@ -351,11 +411,11 @@ def __init__( class Capacity(msrest.serialization.Model): """The object that represents all properties related to capacity enforcement on an account. - :param total_throughput_limit: The total throughput limit imposed on the account. A + :ivar total_throughput_limit: The total throughput limit imposed on the account. A totalThroughputLimit of 2000 imposes a strict limit of max throughput that can be provisioned on that account to be 2000. A totalThroughputLimit of -1 indicates no limits on provisioning of throughput. - :type total_throughput_limit: int + :vartype total_throughput_limit: int """ _validation = { @@ -372,6 +432,13 @@ def __init__( total_throughput_limit: Optional[int] = None, **kwargs ): + """ + :keyword total_throughput_limit: The total throughput limit imposed on the account. A + totalThroughputLimit of 2000 imposes a strict limit of max throughput that can be provisioned + on that account to be 2000. A totalThroughputLimit of -1 indicates no limits on provisioning of + throughput. + :paramtype total_throughput_limit: int + """ super(Capacity, self).__init__(**kwargs) self.total_throughput_limit = total_throughput_limit @@ -379,15 +446,15 @@ def __init__( class CassandraClusterPublicStatus(msrest.serialization.Model): """Properties of a managed Cassandra cluster public status. - :param e_tag: - :type e_tag: str - :param reaper_status: - :type reaper_status: ~azure.mgmt.cosmosdb.models.ManagedCassandraReaperStatus - :param connection_errors: List relevant information about any connection errors to the + :ivar e_tag: + :vartype e_tag: str + :ivar reaper_status: + :vartype reaper_status: ~azure.mgmt.cosmosdb.models.ManagedCassandraReaperStatus + :ivar connection_errors: List relevant information about any connection errors to the Datacenters. - :type connection_errors: list[~azure.mgmt.cosmosdb.models.ConnectionError] - :param data_centers: List of the status of each datacenter in this cluster. - :type data_centers: + :vartype connection_errors: list[~azure.mgmt.cosmosdb.models.ConnectionError] + :ivar data_centers: List of the status of each datacenter in this cluster. + :vartype data_centers: list[~azure.mgmt.cosmosdb.models.CassandraClusterPublicStatusDataCentersItem] """ @@ -407,6 +474,18 @@ def __init__( data_centers: Optional[List["CassandraClusterPublicStatusDataCentersItem"]] = None, **kwargs ): + """ + :keyword e_tag: + :paramtype e_tag: str + :keyword reaper_status: + :paramtype reaper_status: ~azure.mgmt.cosmosdb.models.ManagedCassandraReaperStatus + :keyword connection_errors: List relevant information about any connection errors to the + Datacenters. + :paramtype connection_errors: list[~azure.mgmt.cosmosdb.models.ConnectionError] + :keyword data_centers: List of the status of each datacenter in this cluster. + :paramtype data_centers: + list[~azure.mgmt.cosmosdb.models.CassandraClusterPublicStatusDataCentersItem] + """ super(CassandraClusterPublicStatus, self).__init__(**kwargs) self.e_tag = e_tag self.reaper_status = reaper_status @@ -417,12 +496,12 @@ def __init__( class CassandraClusterPublicStatusDataCentersItem(msrest.serialization.Model): """CassandraClusterPublicStatusDataCentersItem. - :param name: The name of this Datacenter. - :type name: str - :param seed_nodes: A list of all seed nodes in the cluster, managed and unmanaged. - :type seed_nodes: list[str] - :param nodes: - :type nodes: + :ivar name: The name of this Datacenter. + :vartype name: str + :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.ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems] """ @@ -440,6 +519,15 @@ def __init__( nodes: Optional[List["ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems"]] = None, **kwargs ): + """ + :keyword name: The name of this Datacenter. + :paramtype name: str + :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.ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems] + """ super(CassandraClusterPublicStatusDataCentersItem, self).__init__(**kwargs) self.name = name self.seed_nodes = seed_nodes @@ -459,20 +547,20 @@ class CassandraKeyspaceCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a Cassandra keyspace. - :type resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a Cassandra keyspace. + :vartype resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -501,6 +589,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a Cassandra keyspace. + :paramtype resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(CassandraKeyspaceCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -509,11 +613,11 @@ def __init__( class OptionsResource(msrest.serialization.Model): """Cosmos DB options resource object. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -528,6 +632,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(OptionsResource, self).__init__(**kwargs) self.throughput = throughput self.autoscale_settings = autoscale_settings @@ -536,11 +647,11 @@ def __init__( class CassandraKeyspaceGetPropertiesOptions(OptionsResource): """CassandraKeyspaceGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -555,6 +666,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(CassandraKeyspaceGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -563,8 +681,8 @@ class CassandraKeyspaceResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB Cassandra keyspace. - :type id: str + :ivar id: Required. Name of the Cosmos DB Cassandra keyspace. + :vartype id: str """ _validation = { @@ -581,6 +699,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB Cassandra keyspace. + :paramtype id: str + """ super(CassandraKeyspaceResource, self).__init__(**kwargs) self.id = id @@ -615,6 +737,8 @@ def __init__( self, **kwargs ): + """ + """ super(ExtendedResourceProperties, self).__init__(**kwargs) self.rid = None self.ts = None @@ -628,8 +752,8 @@ class CassandraKeyspaceGetPropertiesResource(ExtendedResourceProperties, Cassand All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB Cassandra keyspace. - :type id: str + :ivar id: Required. Name of the Cosmos DB Cassandra keyspace. + :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. @@ -659,6 +783,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB Cassandra keyspace. + :paramtype id: str + """ super(CassandraKeyspaceGetPropertiesResource, self).__init__(id=id, **kwargs) self.id = id self.rid = None @@ -677,19 +805,19 @@ class CassandraKeyspaceGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesOptions """ _validation = { @@ -717,6 +845,21 @@ def __init__( options: Optional["CassandraKeyspaceGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesOptions + """ super(CassandraKeyspaceGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -743,6 +886,8 @@ def __init__( self, **kwargs ): + """ + """ super(CassandraKeyspaceListResult, self).__init__(**kwargs) self.value = None @@ -750,8 +895,8 @@ def __init__( class CassandraPartitionKey(msrest.serialization.Model): """Cosmos DB Cassandra table partition key. - :param name: Name of the Cosmos DB Cassandra table partition key. - :type name: str + :ivar name: Name of the Cosmos DB Cassandra table partition key. + :vartype name: str """ _attribute_map = { @@ -764,6 +909,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the Cosmos DB Cassandra table partition key. + :paramtype name: str + """ super(CassandraPartitionKey, self).__init__(**kwargs) self.name = name @@ -771,12 +920,12 @@ def __init__( class CassandraSchema(msrest.serialization.Model): """Cosmos DB Cassandra table schema. - :param columns: List of Cassandra table columns. - :type columns: list[~azure.mgmt.cosmosdb.models.Column] - :param partition_keys: List of partition key. - :type partition_keys: list[~azure.mgmt.cosmosdb.models.CassandraPartitionKey] - :param cluster_keys: List of cluster key. - :type cluster_keys: list[~azure.mgmt.cosmosdb.models.ClusterKey] + :ivar columns: List of Cassandra table columns. + :vartype columns: list[~azure.mgmt.cosmosdb.models.Column] + :ivar partition_keys: List of partition key. + :vartype partition_keys: list[~azure.mgmt.cosmosdb.models.CassandraPartitionKey] + :ivar cluster_keys: List of cluster key. + :vartype cluster_keys: list[~azure.mgmt.cosmosdb.models.ClusterKey] """ _attribute_map = { @@ -793,6 +942,14 @@ def __init__( cluster_keys: Optional[List["ClusterKey"]] = None, **kwargs ): + """ + :keyword columns: List of Cassandra table columns. + :paramtype columns: list[~azure.mgmt.cosmosdb.models.Column] + :keyword partition_keys: List of partition key. + :paramtype partition_keys: list[~azure.mgmt.cosmosdb.models.CassandraPartitionKey] + :keyword cluster_keys: List of cluster key. + :paramtype cluster_keys: list[~azure.mgmt.cosmosdb.models.ClusterKey] + """ super(CassandraSchema, self).__init__(**kwargs) self.columns = columns self.partition_keys = partition_keys @@ -812,20 +969,20 @@ class CassandraTableCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a Cassandra table. - :type resource: ~azure.mgmt.cosmosdb.models.CassandraTableResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a Cassandra table. + :vartype resource: ~azure.mgmt.cosmosdb.models.CassandraTableResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -854,6 +1011,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a Cassandra table. + :paramtype resource: ~azure.mgmt.cosmosdb.models.CassandraTableResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(CassandraTableCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -862,11 +1035,11 @@ def __init__( class CassandraTableGetPropertiesOptions(OptionsResource): """CassandraTableGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -881,6 +1054,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(CassandraTableGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -889,14 +1069,14 @@ class CassandraTableResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB Cassandra table. - :type id: str - :param default_ttl: Time to live of the Cosmos DB Cassandra table. - :type default_ttl: int - :param schema: Schema of the Cosmos DB Cassandra table. - :type schema: ~azure.mgmt.cosmosdb.models.CassandraSchema - :param analytical_storage_ttl: Analytical TTL. - :type analytical_storage_ttl: int + :ivar id: Required. Name of the Cosmos DB Cassandra table. + :vartype id: str + :ivar default_ttl: Time to live of the Cosmos DB Cassandra table. + :vartype default_ttl: int + :ivar schema: Schema of the Cosmos DB Cassandra table. + :vartype schema: ~azure.mgmt.cosmosdb.models.CassandraSchema + :ivar analytical_storage_ttl: Analytical TTL. + :vartype analytical_storage_ttl: int """ _validation = { @@ -919,6 +1099,16 @@ def __init__( analytical_storage_ttl: Optional[int] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB Cassandra table. + :paramtype id: str + :keyword default_ttl: Time to live of the Cosmos DB Cassandra table. + :paramtype default_ttl: int + :keyword schema: Schema of the Cosmos DB Cassandra table. + :paramtype schema: ~azure.mgmt.cosmosdb.models.CassandraSchema + :keyword analytical_storage_ttl: Analytical TTL. + :paramtype analytical_storage_ttl: int + """ super(CassandraTableResource, self).__init__(**kwargs) self.id = id self.default_ttl = default_ttl @@ -933,14 +1123,14 @@ class CassandraTableGetPropertiesResource(ExtendedResourceProperties, CassandraT All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB Cassandra table. - :type id: str - :param default_ttl: Time to live of the Cosmos DB Cassandra table. - :type default_ttl: int - :param schema: Schema of the Cosmos DB Cassandra table. - :type schema: ~azure.mgmt.cosmosdb.models.CassandraSchema - :param analytical_storage_ttl: Analytical TTL. - :type analytical_storage_ttl: int + :ivar id: Required. Name of the Cosmos DB Cassandra table. + :vartype id: str + :ivar default_ttl: Time to live of the Cosmos DB Cassandra table. + :vartype default_ttl: int + :ivar schema: Schema of the Cosmos DB Cassandra table. + :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. @@ -976,6 +1166,16 @@ def __init__( analytical_storage_ttl: Optional[int] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB Cassandra table. + :paramtype id: str + :keyword default_ttl: Time to live of the Cosmos DB Cassandra table. + :paramtype default_ttl: int + :keyword schema: Schema of the Cosmos DB Cassandra table. + :paramtype schema: ~azure.mgmt.cosmosdb.models.CassandraSchema + :keyword analytical_storage_ttl: Analytical TTL. + :paramtype analytical_storage_ttl: int + """ super(CassandraTableGetPropertiesResource, self).__init__(id=id, default_ttl=default_ttl, schema=schema, analytical_storage_ttl=analytical_storage_ttl, **kwargs) self.id = id self.default_ttl = default_ttl @@ -997,19 +1197,19 @@ class CassandraTableGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.CassandraTableGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.CassandraTableGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.CassandraTableGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.CassandraTableGetPropertiesOptions """ _validation = { @@ -1037,6 +1237,21 @@ def __init__( options: Optional["CassandraTableGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.CassandraTableGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.CassandraTableGetPropertiesOptions + """ super(CassandraTableGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -1063,6 +1278,8 @@ def __init__( self, **kwargs ): + """ + """ super(CassandraTableListResult, self).__init__(**kwargs) self.value = None @@ -1070,8 +1287,8 @@ def __init__( class Certificate(msrest.serialization.Model): """Certificate. - :param pem: PEM formatted public key. - :type pem: str + :ivar pem: PEM formatted public key. + :vartype pem: str """ _attribute_map = { @@ -1084,6 +1301,10 @@ def __init__( pem: Optional[str] = None, **kwargs ): + """ + :keyword pem: PEM formatted public key. + :paramtype pem: str + """ super(Certificate, self).__init__(**kwargs) self.pem = pem @@ -1091,11 +1312,11 @@ def __init__( class ClusterKey(msrest.serialization.Model): """Cosmos DB Cassandra table cluster key. - :param name: Name of the Cosmos DB Cassandra table cluster key. - :type name: str - :param order_by: Order of the Cosmos DB Cassandra table cluster key, only support "Asc" and + :ivar name: Name of the Cosmos DB Cassandra table cluster key. + :vartype name: str + :ivar order_by: Order of the Cosmos DB Cassandra table cluster key, only support "Asc" and "Desc". - :type order_by: str + :vartype order_by: str """ _attribute_map = { @@ -1110,6 +1331,13 @@ def __init__( order_by: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the Cosmos DB Cassandra table cluster key. + :paramtype name: str + :keyword order_by: Order of the Cosmos DB Cassandra table cluster key, only support "Asc" and + "Desc". + :paramtype order_by: str + """ super(ClusterKey, self).__init__(**kwargs) self.name = name self.order_by = order_by @@ -1126,17 +1354,17 @@ class ManagedCassandraARMResourceProperties(msrest.serialization.Model): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 """ _validation = { @@ -1162,6 +1390,19 @@ def __init__( identity: Optional["ManagedCassandraManagedServiceIdentity"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 + """ super(ManagedCassandraARMResourceProperties, self).__init__(**kwargs) self.id = None self.name = None @@ -1182,19 +1423,19 @@ class ClusterResource(ManagedCassandraARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity - :param properties: Properties of a managed Cassandra cluster. - :type properties: ~azure.mgmt.cosmosdb.models.ClusterResourceProperties + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 = { @@ -1222,6 +1463,21 @@ def __init__( properties: Optional["ClusterResourceProperties"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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(ClusterResource, self).__init__(location=location, tags=tags, identity=identity, **kwargs) self.properties = properties @@ -1231,68 +1487,69 @@ class ClusterResourceProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param provisioning_state: The status of the resource at the time the operation was called. + :ivar provisioning_state: The status of the resource at the time the operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :type provisioning_state: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraProvisioningState - :param restore_from_backup_id: To create an empty cluster, omit this field or set it to null. - To restore a backup into a new cluster, set this field to the resource id of the backup. - :type restore_from_backup_id: str - :param delegated_management_subnet_id: Resource id of a subnet that this cluster's management + :vartype provisioning_state: str or + ~azure.mgmt.cosmosdb.models.ManagedCassandraProvisioningState + :ivar restore_from_backup_id: To create an empty cluster, omit this field or set it to null. To + restore a backup into a new cluster, set this field to the resource id of the backup. + :vartype restore_from_backup_id: str + :ivar delegated_management_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 delegated to data centers. The resource id must be of the form '/subscriptions/:code:``/resourceGroups/:code:``/providers/Microsoft.Network/virtualNetworks/:code:``/subnets/:code:``'. - :type delegated_management_subnet_id: str - :param cassandra_version: Which version of Cassandra should this cluster converge to running + :vartype delegated_management_subnet_id: str + :ivar cassandra_version: Which version of Cassandra should this cluster converge to running (e.g., 3.11). When updated, the cluster may take some time to migrate to the new version. - :type cassandra_version: str - :param cluster_name_override: If you need to set the clusterName property in cassandra.yaml to + :vartype cassandra_version: str + :ivar cluster_name_override: If you need to set the clusterName property in cassandra.yaml to something besides the resource name of the cluster, set the value to use on this property. - :type cluster_name_override: str - :param authentication_method: Which authentication method Cassandra should use to authenticate + :vartype cluster_name_override: str + :ivar authentication_method: Which authentication method Cassandra should use to authenticate clients. 'None' turns off authentication, so should not be used except in emergencies. 'Cassandra' is the default password based authentication. The default is 'Cassandra'. Possible values include: "None", "Cassandra". - :type authentication_method: str or ~azure.mgmt.cosmosdb.models.AuthenticationMethod - :param initial_cassandra_admin_password: Initial password for clients connecting as admin to - the cluster. Should be changed after cluster creation. Returns null on GET. This field only - applies when the authenticationMethod field is 'Cassandra'. - :type initial_cassandra_admin_password: str - :param prometheus_endpoint: Hostname or IP address where the Prometheus endpoint containing - data about the managed Cassandra nodes can be reached. - :type prometheus_endpoint: ~azure.mgmt.cosmosdb.models.SeedNode - :param repair_enabled: Should automatic repairs run on this cluster? If omitted, this is true, + :vartype authentication_method: str or ~azure.mgmt.cosmosdb.models.AuthenticationMethod + :ivar initial_cassandra_admin_password: Initial password for clients connecting as admin to the + cluster. Should be changed after cluster creation. Returns null on GET. This field only applies + when the authenticationMethod field is 'Cassandra'. + :vartype initial_cassandra_admin_password: str + :ivar prometheus_endpoint: Hostname or IP address where the Prometheus endpoint containing data + about the managed Cassandra nodes can be reached. + :vartype prometheus_endpoint: ~azure.mgmt.cosmosdb.models.SeedNode + :ivar repair_enabled: Should automatic repairs run on this cluster? If omitted, this is true, and should stay true unless you are running a hybrid cluster where you are already doing your own repairs. - :type repair_enabled: bool - :param client_certificates: List of TLS certificates used to authorize clients connecting to - the cluster. All connections are TLS encrypted whether clientCertificates is set or not, but if + :vartype repair_enabled: bool + :ivar client_certificates: List of TLS certificates used to authorize clients connecting to the + cluster. All connections are TLS encrypted whether clientCertificates is set or not, but if clientCertificates is set, the managed Cassandra cluster will reject all connections not bearing a TLS client certificate that can be validated from one or more of the public certificates in this property. - :type client_certificates: list[~azure.mgmt.cosmosdb.models.Certificate] - :param external_gossip_certificates: List of TLS certificates used to authorize gossip from + :vartype client_certificates: list[~azure.mgmt.cosmosdb.models.Certificate] + :ivar external_gossip_certificates: List of TLS certificates used to authorize gossip from unmanaged data centers. The TLS certificates of all nodes in unmanaged data centers must be verifiable using one of the certificates provided in this property. - :type external_gossip_certificates: list[~azure.mgmt.cosmosdb.models.Certificate] + :vartype external_gossip_certificates: list[~azure.mgmt.cosmosdb.models.Certificate] :ivar gossip_certificates: List of TLS certificates that unmanaged nodes must trust for gossip with managed nodes. All managed nodes will present TLS client certificates that are verifiable using one of the certificates provided in this property. :vartype gossip_certificates: list[~azure.mgmt.cosmosdb.models.Certificate] - :param external_seed_nodes: List of IP addresses of seed nodes in unmanaged data centers. These + :ivar external_seed_nodes: List of IP addresses of seed nodes in unmanaged data centers. These will be added to the seed node lists of all managed nodes. - :type external_seed_nodes: list[~azure.mgmt.cosmosdb.models.SeedNode] + :vartype external_seed_nodes: list[~azure.mgmt.cosmosdb.models.SeedNode] :ivar seed_nodes: List of IP addresses of seed nodes in the managed data centers. These should be added to the seed node lists of all unmanaged nodes. :vartype seed_nodes: list[~azure.mgmt.cosmosdb.models.SeedNode] - :param hours_between_backups: Number of hours to wait between taking a backup of the cluster. - To disable backups, set this property to 0. - :type hours_between_backups: int - :param deallocated: Whether the cluster and associated data centers has been deallocated. - :type deallocated: bool - :param cassandra_audit_logging_enabled: Whether Cassandra audit logging is enabled. - :type cassandra_audit_logging_enabled: bool + :ivar hours_between_backups: Number of hours to wait between taking a backup of the cluster. To + disable backups, set this property to 0. + :vartype hours_between_backups: int + :ivar deallocated: Whether the cluster and associated data centers has been deallocated. + :vartype deallocated: bool + :ivar cassandra_audit_logging_enabled: Whether Cassandra audit logging is enabled. + :vartype cassandra_audit_logging_enabled: bool """ _validation = { @@ -1340,6 +1597,64 @@ def __init__( cassandra_audit_logging_enabled: Optional[bool] = None, **kwargs ): + """ + :keyword provisioning_state: The status of the resource at the time the operation was called. + Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :paramtype provisioning_state: str or + ~azure.mgmt.cosmosdb.models.ManagedCassandraProvisioningState + :keyword restore_from_backup_id: To create an empty cluster, omit this field or set it to null. + To restore a backup into a new cluster, set this field to the resource id of the backup. + :paramtype restore_from_backup_id: str + :keyword delegated_management_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 delegated to data centers. The resource id must be of the form + '/subscriptions/:code:``/resourceGroups/:code:``/providers/Microsoft.Network/virtualNetworks/:code:``/subnets/:code:``'. + :paramtype delegated_management_subnet_id: str + :keyword cassandra_version: Which version of Cassandra should this cluster converge to running + (e.g., 3.11). When updated, the cluster may take some time to migrate to the new version. + :paramtype cassandra_version: str + :keyword cluster_name_override: If you need to set the clusterName property in cassandra.yaml + to something besides the resource name of the cluster, set the value to use on this property. + :paramtype cluster_name_override: str + :keyword authentication_method: Which authentication method Cassandra should use to + authenticate clients. 'None' turns off authentication, so should not be used except in + emergencies. 'Cassandra' is the default password based authentication. The default is + 'Cassandra'. Possible values include: "None", "Cassandra". + :paramtype authentication_method: str or ~azure.mgmt.cosmosdb.models.AuthenticationMethod + :keyword initial_cassandra_admin_password: Initial password for clients connecting as admin to + the cluster. Should be changed after cluster creation. Returns null on GET. This field only + applies when the authenticationMethod field is 'Cassandra'. + :paramtype initial_cassandra_admin_password: str + :keyword prometheus_endpoint: Hostname or IP address where the Prometheus endpoint containing + data about the managed Cassandra nodes can be reached. + :paramtype prometheus_endpoint: ~azure.mgmt.cosmosdb.models.SeedNode + :keyword repair_enabled: Should automatic repairs run on this cluster? If omitted, this is + true, and should stay true unless you are running a hybrid cluster where you are already doing + your own repairs. + :paramtype repair_enabled: bool + :keyword client_certificates: List of TLS certificates used to authorize clients connecting to + the cluster. All connections are TLS encrypted whether clientCertificates is set or not, but if + clientCertificates is set, the managed Cassandra cluster will reject all connections not + bearing a TLS client certificate that can be validated from one or more of the public + certificates in this property. + :paramtype client_certificates: list[~azure.mgmt.cosmosdb.models.Certificate] + :keyword external_gossip_certificates: List of TLS certificates used to authorize gossip from + unmanaged data centers. The TLS certificates of all nodes in unmanaged data centers must be + verifiable using one of the certificates provided in this property. + :paramtype external_gossip_certificates: list[~azure.mgmt.cosmosdb.models.Certificate] + :keyword external_seed_nodes: List of IP addresses of seed nodes in unmanaged data centers. + These will be added to the seed node lists of all managed nodes. + :paramtype external_seed_nodes: list[~azure.mgmt.cosmosdb.models.SeedNode] + :keyword hours_between_backups: Number of hours to wait between taking a backup of the cluster. + To disable backups, set this property to 0. + :paramtype hours_between_backups: int + :keyword deallocated: Whether the cluster and associated data centers has been deallocated. + :paramtype deallocated: bool + :keyword cassandra_audit_logging_enabled: Whether Cassandra audit logging is enabled. + :paramtype cassandra_audit_logging_enabled: bool + """ super(ClusterResourceProperties, self).__init__(**kwargs) self.provisioning_state = provisioning_state self.restore_from_backup_id = restore_from_backup_id @@ -1363,10 +1678,10 @@ def __init__( class Column(msrest.serialization.Model): """Cosmos DB Cassandra table column. - :param name: Name of the Cosmos DB Cassandra table column. - :type name: str - :param type: Type of the Cosmos DB Cassandra table column. - :type type: str + :ivar name: Name of the Cosmos DB Cassandra table column. + :vartype name: str + :ivar type: Type of the Cosmos DB Cassandra table column. + :vartype type: str """ _attribute_map = { @@ -1381,6 +1696,12 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the Cosmos DB Cassandra table column. + :paramtype name: str + :keyword type: Type of the Cosmos DB Cassandra table column. + :paramtype type: str + """ super(Column, self).__init__(**kwargs) self.name = name self.type = type @@ -1389,8 +1710,8 @@ def __init__( class CommandOutput(msrest.serialization.Model): """Response of /command api. - :param command_output: Output of the command. - :type command_output: str + :ivar command_output: Output of the command. + :vartype command_output: str """ _attribute_map = { @@ -1403,6 +1724,10 @@ def __init__( command_output: Optional[str] = None, **kwargs ): + """ + :keyword command_output: Output of the command. + :paramtype command_output: str + """ super(CommandOutput, self).__init__(**kwargs) self.command_output = command_output @@ -1412,18 +1737,18 @@ class CommandPostBody(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param command: Required. The command which should be run. - :type command: str - :param arguments: The arguments for the command to be run. - :type arguments: dict[str, str] - :param host: Required. IP address of the cassandra host to run the command on. - :type host: str - :param cassandra_stop_start: If true, stops cassandra before executing the command and then + :ivar command: Required. The command which should be run. + :vartype command: str + :ivar arguments: The arguments for the command to be run. + :vartype arguments: dict[str, str] + :ivar host: Required. IP address of the cassandra host to run the command on. + :vartype host: str + :ivar cassandra_stop_start: If true, stops cassandra before executing the command and then start it again. - :type cassandra_stop_start: bool - :param readwrite: If true, allows the command to *write* to the cassandra directory, otherwise + :vartype cassandra_stop_start: bool + :ivar readwrite: If true, allows the command to *write* to the cassandra directory, otherwise read-only. - :type readwrite: bool + :vartype readwrite: bool """ _validation = { @@ -1449,6 +1774,20 @@ def __init__( readwrite: Optional[bool] = None, **kwargs ): + """ + :keyword command: Required. The command which should be run. + :paramtype command: str + :keyword arguments: The arguments for the command to be run. + :paramtype arguments: dict[str, str] + :keyword host: Required. IP address of the cassandra host to run the command on. + :paramtype host: str + :keyword cassandra_stop_start: If true, stops cassandra before executing the command and then + start it again. + :paramtype cassandra_stop_start: bool + :keyword readwrite: If true, allows the command to *write* to the cassandra directory, + otherwise read-only. + :paramtype readwrite: bool + """ super(CommandPostBody, self).__init__(**kwargs) self.command = command self.arguments = arguments @@ -1482,6 +1821,8 @@ def __init__( self, **kwargs ): + """ + """ super(Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1490,43 +1831,42 @@ def __init__( class ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems(msrest.serialization.Model): """ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems. - :param address: The node's IP address. - :type address: str - :param state: The state of the node in Cassandra ring. Possible values include: "Normal", + :ivar address: The node's IP address. + :vartype address: str + :ivar state: The state of the node in Cassandra ring. Possible values include: "Normal", "Leaving", "Joining", "Moving", "Stopped". - :type state: str or ~azure.mgmt.cosmosdb.models.NodeState - :param status: - :type status: str - :param load: The amount of file system data in the data directory (e.g., 47.66 kB), excluding + :vartype state: str or ~azure.mgmt.cosmosdb.models.NodeState + :ivar status: + :vartype 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. - :type load: str - :param tokens: List of tokens this node covers. - :type tokens: list[str] - :param size: - :type size: int - :param host_id: The network ID of the node. - :type host_id: str - :param rack: The rack this node is part of. - :type rack: str - :param timestamp: The timestamp when these statistics were captured. - :type timestamp: str - :param disk_used_kb: The amount of disk used, in kB, of the directory /var/lib/cassandra. - :type disk_used_kb: long - :param disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. - :type disk_free_kb: long - :param memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. - :type memory_used_kb: long - :param memory_buffers_and_cached_kb: Memory used by kernel buffers (Buffers in /proc/meminfo) + :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: long + :ivar disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. + :vartype disk_free_kb: long + :ivar memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. + :vartype memory_used_kb: long + :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. - :type memory_buffers_and_cached_kb: long - :param memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. - :type memory_free_kb: long - :param memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in - kB. - :type memory_total_kb: long - :param cpu_usage: A float representing the current system-wide CPU utilization as a percentage. - :type cpu_usage: float + :vartype memory_buffers_and_cached_kb: long + :ivar memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. + :vartype memory_free_kb: long + :ivar memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in kB. + :vartype memory_total_kb: long + :ivar cpu_usage: A float representing the current system-wide CPU utilization as a percentage. + :vartype cpu_usage: float """ _attribute_map = { @@ -1569,6 +1909,46 @@ def __init__( cpu_usage: Optional[float] = None, **kwargs ): + """ + :keyword address: The node's IP address. + :paramtype address: str + :keyword state: The state of the node in Cassandra ring. Possible values include: "Normal", + "Leaving", "Joining", "Moving", "Stopped". + :paramtype state: str or ~azure.mgmt.cosmosdb.models.NodeState + :keyword status: + :paramtype 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: long + :keyword disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. + :paramtype disk_free_kb: long + :keyword memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. + :paramtype memory_used_kb: long + :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: long + :keyword memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. + :paramtype memory_free_kb: long + :keyword memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in + kB. + :paramtype memory_total_kb: long + :keyword cpu_usage: A float representing the current system-wide CPU utilization as a + percentage. + :paramtype cpu_usage: float + """ super(ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems, self).__init__(**kwargs) self.address = address self.state = state @@ -1591,12 +1971,12 @@ def __init__( class CompositePath(msrest.serialization.Model): """CompositePath. - :param path: The path for which the indexing behavior applies to. Index paths typically start + :ivar path: The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*). - :type path: str - :param order: Sort order for composite paths. Possible values include: "ascending", + :vartype path: str + :ivar order: Sort order for composite paths. Possible values include: "ascending", "descending". - :type order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder + :vartype order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder """ _attribute_map = { @@ -1611,6 +1991,14 @@ def __init__( order: Optional[Union[str, "CompositePathSortOrder"]] = None, **kwargs ): + """ + :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. Possible values include: "ascending", + "descending". + :paramtype order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder + """ super(CompositePath, self).__init__(**kwargs) self.path = path self.order = order @@ -1619,15 +2007,15 @@ def __init__( class ConflictResolutionPolicy(msrest.serialization.Model): """The conflict resolution policy for the container. - :param mode: Indicates the conflict resolution mode. Possible values include: "LastWriterWins", + :ivar mode: Indicates the conflict resolution mode. Possible values include: "LastWriterWins", "Custom". Default value: "LastWriterWins". - :type mode: str or ~azure.mgmt.cosmosdb.models.ConflictResolutionMode - :param conflict_resolution_path: The conflict resolution path in the case of LastWriterWins + :vartype mode: str or ~azure.mgmt.cosmosdb.models.ConflictResolutionMode + :ivar conflict_resolution_path: The conflict resolution path in the case of LastWriterWins mode. - :type conflict_resolution_path: str - :param conflict_resolution_procedure: The procedure to resolve conflicts in the case of custom + :vartype conflict_resolution_path: str + :ivar conflict_resolution_procedure: The procedure to resolve conflicts in the case of custom mode. - :type conflict_resolution_procedure: str + :vartype conflict_resolution_procedure: str """ _attribute_map = { @@ -1644,6 +2032,17 @@ def __init__( conflict_resolution_procedure: Optional[str] = None, **kwargs ): + """ + :keyword mode: Indicates the conflict resolution mode. Possible values include: + "LastWriterWins", "Custom". Default value: "LastWriterWins". + :paramtype mode: str or ~azure.mgmt.cosmosdb.models.ConflictResolutionMode + :keyword conflict_resolution_path: The conflict resolution path in the case of LastWriterWins + mode. + :paramtype conflict_resolution_path: str + :keyword conflict_resolution_procedure: The procedure to resolve conflicts in the case of + custom mode. + :paramtype conflict_resolution_procedure: str + """ super(ConflictResolutionPolicy, self).__init__(**kwargs) self.mode = mode self.conflict_resolution_path = conflict_resolution_path @@ -1653,18 +2052,18 @@ def __init__( class ConnectionError(msrest.serialization.Model): """ConnectionError. - :param connection_state: The kind of connection error that occurred. Possible values include: + :ivar connection_state: The kind of connection error that occurred. Possible values include: "Unknown", "OK", "OperatorToDataCenterNetworkError", "DatacenterToDatacenterNetworkError", "InternalOperatorToDataCenterCertificateError", "InternalError". - :type connection_state: str or ~azure.mgmt.cosmosdb.models.ConnectionState - :param i_p_from: The IP of host that originated the failed connection. - :type i_p_from: str - :param i_p_to: The IP that the connection attempted to reach. - :type i_p_to: str - :param port: The TCP port the connection was attempted on. - :type port: int - :param exception: Detailed error message about the failed connection. - :type exception: str + :vartype connection_state: str or ~azure.mgmt.cosmosdb.models.ConnectionState + :ivar i_p_from: The IP of host that originated the failed connection. + :vartype i_p_from: str + :ivar i_p_to: The IP that the connection attempted to reach. + :vartype i_p_to: str + :ivar port: The TCP port the connection was attempted on. + :vartype port: int + :ivar exception: Detailed error message about the failed connection. + :vartype exception: str """ _attribute_map = { @@ -1685,6 +2084,20 @@ def __init__( exception: Optional[str] = None, **kwargs ): + """ + :keyword connection_state: The kind of connection error that occurred. Possible values include: + "Unknown", "OK", "OperatorToDataCenterNetworkError", "DatacenterToDatacenterNetworkError", + "InternalOperatorToDataCenterCertificateError", "InternalError". + :paramtype connection_state: str or ~azure.mgmt.cosmosdb.models.ConnectionState + :keyword i_p_from: The IP of host that originated the failed connection. + :paramtype i_p_from: str + :keyword i_p_to: The IP that the connection attempted to reach. + :paramtype i_p_to: str + :keyword port: The TCP port the connection was attempted on. + :paramtype port: int + :keyword exception: Detailed error message about the failed connection. + :paramtype exception: str + """ super(ConnectionError, self).__init__(**kwargs) self.connection_state = connection_state self.i_p_from = i_p_from @@ -1698,18 +2111,18 @@ class ConsistencyPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param default_consistency_level: Required. The default consistency level and configuration + :ivar default_consistency_level: Required. The default consistency level and configuration settings of the Cosmos DB account. Possible values include: "Eventual", "Session", "BoundedStaleness", "Strong", "ConsistentPrefix". - :type default_consistency_level: str or ~azure.mgmt.cosmosdb.models.DefaultConsistencyLevel - :param max_staleness_prefix: When used with the Bounded Staleness consistency level, this value + :vartype default_consistency_level: str or ~azure.mgmt.cosmosdb.models.DefaultConsistencyLevel + :ivar max_staleness_prefix: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 – 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. - :type max_staleness_prefix: long - :param max_interval_in_seconds: When used with the Bounded Staleness consistency level, this + :vartype max_staleness_prefix: long + :ivar max_interval_in_seconds: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. - :type max_interval_in_seconds: int + :vartype max_interval_in_seconds: int """ _validation = { @@ -1732,6 +2145,21 @@ def __init__( max_interval_in_seconds: Optional[int] = None, **kwargs ): + """ + :keyword default_consistency_level: Required. The default consistency level and configuration + settings of the Cosmos DB account. Possible values include: "Eventual", "Session", + "BoundedStaleness", "Strong", "ConsistentPrefix". + :paramtype default_consistency_level: str or + ~azure.mgmt.cosmosdb.models.DefaultConsistencyLevel + :keyword max_staleness_prefix: When used with the Bounded Staleness consistency level, this + value represents the number of stale requests tolerated. Accepted range for this value is 1 – + 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. + :paramtype max_staleness_prefix: long + :keyword max_interval_in_seconds: When used with the Bounded Staleness consistency level, this + value represents the time amount of staleness (in seconds) tolerated. Accepted range for this + value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. + :paramtype max_interval_in_seconds: int + """ super(ConsistencyPolicy, self).__init__(**kwargs) self.default_consistency_level = default_consistency_level self.max_staleness_prefix = max_staleness_prefix @@ -1743,14 +2171,14 @@ class ContainerPartitionKey(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param paths: List of paths using which data within the container can be partitioned. - :type paths: list[str] - :param kind: Indicates the kind of algorithm used for partitioning. For MultiHash, multiple + :ivar paths: List of paths using which data within the container can be partitioned. + :vartype paths: list[str] + :ivar kind: Indicates the kind of algorithm used for partitioning. For MultiHash, multiple partition keys (upto three maximum) are supported for container create. Possible values include: "Hash", "Range", "MultiHash". Default value: "Hash". - :type kind: str or ~azure.mgmt.cosmosdb.models.PartitionKind - :param version: Indicates the version of the partition key definition. - :type version: int + :vartype kind: str or ~azure.mgmt.cosmosdb.models.PartitionKind + :ivar version: Indicates the version of the partition key definition. + :vartype version: int :ivar system_key: Indicates if the container is using a system generated partition key. :vartype system_key: bool """ @@ -1775,6 +2203,16 @@ def __init__( version: Optional[int] = None, **kwargs ): + """ + :keyword paths: List of paths using which data within the container can be partitioned. + :paramtype paths: list[str] + :keyword kind: Indicates the kind of algorithm used for partitioning. For MultiHash, multiple + partition keys (upto three maximum) are supported for container create. Possible values + include: "Hash", "Range", "MultiHash". Default value: "Hash". + :paramtype kind: str or ~azure.mgmt.cosmosdb.models.PartitionKind + :keyword version: Indicates the version of the partition key definition. + :paramtype version: int + """ super(ContainerPartitionKey, self).__init__(**kwargs) self.paths = paths self.kind = kind @@ -1785,8 +2223,8 @@ def __init__( class ContinuousBackupInformation(msrest.serialization.Model): """Information about the status of continuous backups. - :param latest_restorable_timestamp: The latest restorable timestamp for a resource. - :type latest_restorable_timestamp: str + :ivar latest_restorable_timestamp: The latest restorable timestamp for a resource. + :vartype latest_restorable_timestamp: str """ _attribute_map = { @@ -1799,6 +2237,10 @@ def __init__( latest_restorable_timestamp: Optional[str] = None, **kwargs ): + """ + :keyword latest_restorable_timestamp: The latest restorable timestamp for a resource. + :paramtype latest_restorable_timestamp: str + """ super(ContinuousBackupInformation, self).__init__(**kwargs) self.latest_restorable_timestamp = latest_restorable_timestamp @@ -1806,8 +2248,8 @@ def __init__( class ContinuousBackupRestoreLocation(msrest.serialization.Model): """Properties of the regional restorable account. - :param location: The name of the continuous backup restore location. - :type location: str + :ivar location: The name of the continuous backup restore location. + :vartype location: str """ _attribute_map = { @@ -1820,6 +2262,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The name of the continuous backup restore location. + :paramtype location: str + """ super(ContinuousBackupRestoreLocation, self).__init__(**kwargs) self.location = location @@ -1829,12 +2275,12 @@ class ContinuousModeBackupPolicy(BackupPolicy): All required parameters must be populated in order to send to Azure. - :param type: Required. Describes the mode of backups.Constant filled by server. Possible - values include: "Periodic", "Continuous". - :type type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType - :param migration_state: The object representing the state of the migration between the backup + :ivar type: Required. Describes the mode of backups.Constant filled by server. Possible values + include: "Periodic", "Continuous". + :vartype type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType + :ivar migration_state: The object representing the state of the migration between the backup policies. - :type migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState + :vartype migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState """ _validation = { @@ -1852,6 +2298,11 @@ def __init__( migration_state: Optional["BackupPolicyMigrationState"] = None, **kwargs ): + """ + :keyword migration_state: The object representing the state of the migration between the backup + policies. + :paramtype migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState + """ super(ContinuousModeBackupPolicy, self).__init__(migration_state=migration_state, **kwargs) self.type = 'Continuous' # type: str @@ -1861,21 +2312,21 @@ class CorsPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param allowed_origins: Required. The origin domains that are permitted to make a request + :ivar allowed_origins: Required. The origin domains that are permitted to make a request against the service via CORS. - :type allowed_origins: str - :param allowed_methods: The methods (HTTP request verbs) that the origin domain may use for a + :vartype allowed_origins: str + :ivar allowed_methods: The methods (HTTP request verbs) that the origin domain may use for a CORS request. - :type allowed_methods: str - :param allowed_headers: The request headers that the origin domain may specify on the CORS + :vartype allowed_methods: str + :ivar allowed_headers: The request headers that the origin domain may specify on the CORS request. - :type allowed_headers: str - :param exposed_headers: The response headers that may be sent in the response to the CORS + :vartype allowed_headers: str + :ivar exposed_headers: The response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer. - :type exposed_headers: str - :param max_age_in_seconds: The maximum amount time that a browser should cache the preflight + :vartype exposed_headers: str + :ivar max_age_in_seconds: The maximum amount time that a browser should cache the preflight OPTIONS request. - :type max_age_in_seconds: long + :vartype max_age_in_seconds: long """ _validation = { @@ -1901,6 +2352,23 @@ def __init__( max_age_in_seconds: Optional[int] = None, **kwargs ): + """ + :keyword allowed_origins: Required. The origin domains that are permitted to make a request + against the service via CORS. + :paramtype allowed_origins: str + :keyword allowed_methods: The methods (HTTP request verbs) that the origin domain may use for a + CORS request. + :paramtype allowed_methods: str + :keyword allowed_headers: The request headers that the origin domain may specify on the CORS + request. + :paramtype allowed_headers: str + :keyword exposed_headers: The response headers that may be sent in the response to the CORS + request and exposed by the browser to the request issuer. + :paramtype exposed_headers: str + :keyword max_age_in_seconds: The maximum amount time that a browser should cache the preflight + OPTIONS request. + :paramtype max_age_in_seconds: long + """ super(CorsPolicy, self).__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods @@ -1912,10 +2380,10 @@ def __init__( class CreateUpdateOptions(msrest.serialization.Model): """CreateUpdateOptions are a list of key-value pairs that describe the resource. Supported keys are "If-Match", "If-None-Match", "Session-Token" and "Throughput". - :param throughput: Request Units per second. For example, "throughput": 10000. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :ivar throughput: Request Units per second. For example, "throughput": 10000. + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -1930,6 +2398,12 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Request Units per second. For example, "throughput": 10000. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(CreateUpdateOptions, self).__init__(**kwargs) self.throughput = throughput self.autoscale_settings = autoscale_settings @@ -1960,6 +2434,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseAccountConnectionString, self).__init__(**kwargs) self.connection_string = None self.description = None @@ -1978,92 +2454,92 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param kind: Indicates the type of database account. This can only be set at database account + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 kind: Indicates the type of database account. This can only be set at database account creation. Possible values include: "GlobalDocumentDB", "MongoDB", "Parse". - :type kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :param consistency_policy: The consistency policy for the Cosmos DB account. - :type consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy - :param locations: Required. An array that contains the georeplication locations enabled for the + :vartype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity + :ivar consistency_policy: The consistency policy for the Cosmos DB account. + :vartype consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy + :ivar locations: Required. An array that contains the georeplication locations enabled for the Cosmos DB account. - :type locations: list[~azure.mgmt.cosmosdb.models.Location] + :vartype locations: list[~azure.mgmt.cosmosdb.models.Location] :ivar database_account_offer_type: The offer type for the database. Has constant value: "Standard". :vartype database_account_offer_type: str - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] - :param is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual + :ivar ip_rules: List of IpRules. + :vartype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] + :ivar is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual Network ACL rules. - :type is_virtual_network_filter_enabled: bool - :param enable_automatic_failover: Enables automatic failover of the write region in the rare + :vartype is_virtual_network_filter_enabled: bool + :ivar enable_automatic_failover: Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. - :type enable_automatic_failover: bool - :param capabilities: List of Cosmos DB capabilities for the account. - :type capabilities: list[~azure.mgmt.cosmosdb.models.Capability] - :param virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB + :vartype enable_automatic_failover: bool + :ivar capabilities: List of Cosmos DB capabilities for the account. + :vartype capabilities: list[~azure.mgmt.cosmosdb.models.Capability] + :ivar virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB account. - :type virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] - :param enable_multiple_write_locations: Enables the account to write in multiple locations. - :type enable_multiple_write_locations: bool - :param enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* account. - :type enable_cassandra_connector: bool - :param connector_offer: The cassandra connector offer type for the Cosmos DB database C* + :vartype virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] + :ivar enable_multiple_write_locations: Enables the account to write in multiple locations. + :vartype enable_multiple_write_locations: bool + :ivar enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* account. + :vartype enable_cassandra_connector: bool + :ivar connector_offer: The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: "Small". - :type connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer - :param disable_key_based_metadata_write_access: Disable write operations on metadata resources + :vartype connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer + :ivar disable_key_based_metadata_write_access: Disable write operations on metadata resources (databases, containers, throughput) via account keys. - :type disable_key_based_metadata_write_access: bool - :param key_vault_key_uri: The URI of the key vault. - :type key_vault_key_uri: str - :param default_identity: The default identity for accessing key vault used in features like + :vartype disable_key_based_metadata_write_access: bool + :ivar key_vault_key_uri: The URI of the key vault. + :vartype key_vault_key_uri: str + :ivar default_identity: The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. - :type default_identity: str - :param public_network_access: Whether requests from Public Network are allowed. Possible values + :vartype default_identity: str + :ivar public_network_access: Whether requests from Public Network are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess - :param enable_free_tier: Flag to indicate whether Free Tier is enabled. - :type enable_free_tier: bool - :param api_properties: API specific properties. Currently, supported only for MongoDB API. - :type api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties - :param enable_analytical_storage: Flag to indicate whether to enable storage analytics. - :type enable_analytical_storage: bool - :param analytical_storage_configuration: Analytical storage specific properties. - :type analytical_storage_configuration: + :vartype public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess + :ivar enable_free_tier: Flag to indicate whether Free Tier is enabled. + :vartype enable_free_tier: bool + :ivar api_properties: API specific properties. Currently, supported only for MongoDB API. + :vartype api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties + :ivar enable_analytical_storage: Flag to indicate whether to enable storage analytics. + :vartype enable_analytical_storage: bool + :ivar analytical_storage_configuration: Analytical storage specific properties. + :vartype analytical_storage_configuration: ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration - :param create_mode: Enum to indicate the mode of account creation. Possible values include: + :ivar create_mode: Enum to indicate the mode of account creation. Possible values include: "Default", "Restore". Default value: "Default". - :type create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode - :param backup_policy: The object representing the policy for taking backups on an account. - :type backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy - :param cors: The CORS policy for the Cosmos DB database account. - :type cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] - :param network_acl_bypass: Indicates what services are allowed to bypass firewall checks. + :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode + :ivar backup_policy: The object representing the policy for taking backups on an account. + :vartype backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy + :ivar cors: The CORS policy for the Cosmos DB database account. + :vartype cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] + :ivar network_acl_bypass: Indicates what services are allowed to bypass firewall checks. Possible values include: "None", "AzureServices". - :type network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass - :param network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network Acl + :vartype network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass + :ivar network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. - :type network_acl_bypass_resource_ids: list[str] - :param disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be + :vartype network_acl_bypass_resource_ids: list[str] + :ivar disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. - :type disable_local_auth: bool - :param restore_parameters: Parameters to indicate the information about the restore. - :type restore_parameters: ~azure.mgmt.cosmosdb.models.RestoreParameters - :param capacity: The object that represents all properties related to capacity enforcement on - an account. - :type capacity: ~azure.mgmt.cosmosdb.models.Capacity + :vartype disable_local_auth: bool + :ivar restore_parameters: Parameters to indicate the information about the restore. + :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.RestoreParameters + :ivar capacity: The object that represents all properties related to capacity enforcement on an + account. + :vartype capacity: ~azure.mgmt.cosmosdb.models.Capacity """ _validation = { @@ -2148,6 +2624,92 @@ def __init__( capacity: Optional["Capacity"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 kind: Indicates the type of database account. This can only be set at database account + creation. Possible values include: "GlobalDocumentDB", "MongoDB", "Parse". + :paramtype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity + :keyword consistency_policy: The consistency policy for the Cosmos DB account. + :paramtype consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy + :keyword locations: Required. An array that contains the georeplication locations enabled for + the Cosmos DB account. + :paramtype locations: list[~azure.mgmt.cosmosdb.models.Location] + :keyword ip_rules: List of IpRules. + :paramtype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] + :keyword is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual + Network ACL rules. + :paramtype is_virtual_network_filter_enabled: bool + :keyword enable_automatic_failover: Enables automatic failover of the write region in the rare + event that the region is unavailable due to an outage. Automatic failover will result in a new + write region for the account and is chosen based on the failover priorities configured for the + account. + :paramtype enable_automatic_failover: bool + :keyword capabilities: List of Cosmos DB capabilities for the account. + :paramtype capabilities: list[~azure.mgmt.cosmosdb.models.Capability] + :keyword virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB + account. + :paramtype virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] + :keyword enable_multiple_write_locations: Enables the account to write in multiple locations. + :paramtype enable_multiple_write_locations: bool + :keyword enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* + account. + :paramtype enable_cassandra_connector: bool + :keyword connector_offer: The cassandra connector offer type for the Cosmos DB database C* + account. Possible values include: "Small". + :paramtype connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer + :keyword disable_key_based_metadata_write_access: Disable write operations on metadata + resources (databases, containers, throughput) via account keys. + :paramtype disable_key_based_metadata_write_access: bool + :keyword key_vault_key_uri: The URI of the key vault. + :paramtype key_vault_key_uri: str + :keyword default_identity: The default identity for accessing key vault used in features like + customer managed keys. The default identity needs to be explicitly set by the users. It can be + "FirstPartyIdentity", "SystemAssignedIdentity" and more. + :paramtype default_identity: str + :keyword public_network_access: Whether requests from Public Network are allowed. Possible + values include: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess + :keyword enable_free_tier: Flag to indicate whether Free Tier is enabled. + :paramtype enable_free_tier: bool + :keyword api_properties: API specific properties. Currently, supported only for MongoDB API. + :paramtype api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties + :keyword enable_analytical_storage: Flag to indicate whether to enable storage analytics. + :paramtype enable_analytical_storage: bool + :keyword analytical_storage_configuration: Analytical storage specific properties. + :paramtype analytical_storage_configuration: + ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration + :keyword create_mode: Enum to indicate the mode of account creation. Possible values include: + "Default", "Restore". Default value: "Default". + :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode + :keyword backup_policy: The object representing the policy for taking backups on an account. + :paramtype backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy + :keyword cors: The CORS policy for the Cosmos DB database account. + :paramtype cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] + :keyword network_acl_bypass: Indicates what services are allowed to bypass firewall checks. + Possible values include: "None", "AzureServices". + :paramtype network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass + :keyword network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network + Acl Bypass for the Cosmos DB account. + :paramtype network_acl_bypass_resource_ids: list[str] + :keyword disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be + used exclusively for authentication. + :paramtype disable_local_auth: bool + :keyword restore_parameters: Parameters to indicate the information about the restore. + :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.RestoreParameters + :keyword capacity: The object that represents all properties related to capacity enforcement on + an account. + :paramtype capacity: ~azure.mgmt.cosmosdb.models.Capacity + """ super(DatabaseAccountCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.kind = kind self.identity = identity @@ -2190,20 +2752,20 @@ class DatabaseAccountGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param kind: Indicates the type of database account. This can only be set at database account + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 kind: Indicates the type of database account. This can only be set at database account creation. Possible values include: "GlobalDocumentDB", "MongoDB", "Parse". - :type kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity + :vartype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData :ivar provisioning_state: The status of the Cosmos DB account at the time the operation was @@ -2220,20 +2782,20 @@ class DatabaseAccountGetResults(ARMResourceProperties): value: Standard. The only acceptable values to pass in are None and "Standard". The default value is None. :vartype database_account_offer_type: str - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] - :param is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual + :ivar ip_rules: List of IpRules. + :vartype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] + :ivar is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual Network ACL rules. - :type is_virtual_network_filter_enabled: bool - :param enable_automatic_failover: Enables automatic failover of the write region in the rare + :vartype is_virtual_network_filter_enabled: bool + :ivar enable_automatic_failover: Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. - :type enable_automatic_failover: bool - :param consistency_policy: The consistency policy for the Cosmos DB database account. - :type consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy - :param capabilities: List of Cosmos DB capabilities for the account. - :type capabilities: list[~azure.mgmt.cosmosdb.models.Capability] + :vartype enable_automatic_failover: bool + :ivar consistency_policy: The consistency policy for the Cosmos DB database account. + :vartype consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy + :ivar capabilities: List of Cosmos DB capabilities for the account. + :vartype capabilities: list[~azure.mgmt.cosmosdb.models.Capability] :ivar write_locations: An array that contains the write location for the Cosmos DB account. :vartype write_locations: list[~azure.mgmt.cosmosdb.models.Location] :ivar read_locations: An array that contains of the read locations enabled for the Cosmos DB @@ -2244,64 +2806,64 @@ class DatabaseAccountGetResults(ARMResourceProperties): :ivar failover_policies: An array that contains the regions ordered by their failover priorities. :vartype failover_policies: list[~azure.mgmt.cosmosdb.models.FailoverPolicy] - :param virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB + :ivar virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB account. - :type virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] + :vartype virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] :ivar private_endpoint_connections: List of Private Endpoint Connections configured for the Cosmos DB account. :vartype private_endpoint_connections: list[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] - :param enable_multiple_write_locations: Enables the account to write in multiple locations. - :type enable_multiple_write_locations: bool - :param enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* account. - :type enable_cassandra_connector: bool - :param connector_offer: The cassandra connector offer type for the Cosmos DB database C* + :ivar enable_multiple_write_locations: Enables the account to write in multiple locations. + :vartype enable_multiple_write_locations: bool + :ivar enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* account. + :vartype enable_cassandra_connector: bool + :ivar connector_offer: The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: "Small". - :type connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer - :param disable_key_based_metadata_write_access: Disable write operations on metadata resources + :vartype connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer + :ivar disable_key_based_metadata_write_access: Disable write operations on metadata resources (databases, containers, throughput) via account keys. - :type disable_key_based_metadata_write_access: bool - :param key_vault_key_uri: The URI of the key vault. - :type key_vault_key_uri: str - :param default_identity: The default identity for accessing key vault used in features like + :vartype disable_key_based_metadata_write_access: bool + :ivar key_vault_key_uri: The URI of the key vault. + :vartype key_vault_key_uri: str + :ivar default_identity: The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. - :type default_identity: str - :param public_network_access: Whether requests from Public Network are allowed. Possible values + :vartype default_identity: str + :ivar public_network_access: Whether requests from Public Network are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess - :param enable_free_tier: Flag to indicate whether Free Tier is enabled. - :type enable_free_tier: bool - :param api_properties: API specific properties. - :type api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties - :param enable_analytical_storage: Flag to indicate whether to enable storage analytics. - :type enable_analytical_storage: bool - :param analytical_storage_configuration: Analytical storage specific properties. - :type analytical_storage_configuration: + :vartype public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess + :ivar enable_free_tier: Flag to indicate whether Free Tier is enabled. + :vartype enable_free_tier: bool + :ivar api_properties: API specific properties. + :vartype api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties + :ivar enable_analytical_storage: Flag to indicate whether to enable storage analytics. + :vartype enable_analytical_storage: bool + :ivar analytical_storage_configuration: Analytical storage specific properties. + :vartype analytical_storage_configuration: ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration :ivar instance_id: A unique identifier assigned to the database account. :vartype instance_id: str - :param create_mode: Enum to indicate the mode of account creation. Possible values include: + :ivar create_mode: Enum to indicate the mode of account creation. Possible values include: "Default", "Restore". Default value: "Default". - :type create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode - :param restore_parameters: Parameters to indicate the information about the restore. - :type restore_parameters: ~azure.mgmt.cosmosdb.models.RestoreParameters - :param backup_policy: The object representing the policy for taking backups on an account. - :type backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy - :param cors: The CORS policy for the Cosmos DB database account. - :type cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] - :param network_acl_bypass: Indicates what services are allowed to bypass firewall checks. + :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode + :ivar restore_parameters: Parameters to indicate the information about the restore. + :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.RestoreParameters + :ivar backup_policy: The object representing the policy for taking backups on an account. + :vartype backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy + :ivar cors: The CORS policy for the Cosmos DB database account. + :vartype cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] + :ivar network_acl_bypass: Indicates what services are allowed to bypass firewall checks. Possible values include: "None", "AzureServices". - :type network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass - :param network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network Acl + :vartype network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass + :ivar network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. - :type network_acl_bypass_resource_ids: list[str] - :param disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be + :vartype network_acl_bypass_resource_ids: list[str] + :ivar disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. - :type disable_local_auth: bool - :param capacity: The object that represents all properties related to capacity enforcement on - an account. - :type capacity: ~azure.mgmt.cosmosdb.models.Capacity + :vartype disable_local_auth: bool + :ivar capacity: The object that represents all properties related to capacity enforcement on an + account. + :vartype capacity: ~azure.mgmt.cosmosdb.models.Capacity """ _validation = { @@ -2399,6 +2961,89 @@ def __init__( capacity: Optional["Capacity"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 kind: Indicates the type of database account. This can only be set at database account + creation. Possible values include: "GlobalDocumentDB", "MongoDB", "Parse". + :paramtype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity + :keyword ip_rules: List of IpRules. + :paramtype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] + :keyword is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual + Network ACL rules. + :paramtype is_virtual_network_filter_enabled: bool + :keyword enable_automatic_failover: Enables automatic failover of the write region in the rare + event that the region is unavailable due to an outage. Automatic failover will result in a new + write region for the account and is chosen based on the failover priorities configured for the + account. + :paramtype enable_automatic_failover: bool + :keyword consistency_policy: The consistency policy for the Cosmos DB database account. + :paramtype consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy + :keyword capabilities: List of Cosmos DB capabilities for the account. + :paramtype capabilities: list[~azure.mgmt.cosmosdb.models.Capability] + :keyword virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB + account. + :paramtype virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] + :keyword enable_multiple_write_locations: Enables the account to write in multiple locations. + :paramtype enable_multiple_write_locations: bool + :keyword enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* + account. + :paramtype enable_cassandra_connector: bool + :keyword connector_offer: The cassandra connector offer type for the Cosmos DB database C* + account. Possible values include: "Small". + :paramtype connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer + :keyword disable_key_based_metadata_write_access: Disable write operations on metadata + resources (databases, containers, throughput) via account keys. + :paramtype disable_key_based_metadata_write_access: bool + :keyword key_vault_key_uri: The URI of the key vault. + :paramtype key_vault_key_uri: str + :keyword default_identity: The default identity for accessing key vault used in features like + customer managed keys. The default identity needs to be explicitly set by the users. It can be + "FirstPartyIdentity", "SystemAssignedIdentity" and more. + :paramtype default_identity: str + :keyword public_network_access: Whether requests from Public Network are allowed. Possible + values include: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess + :keyword enable_free_tier: Flag to indicate whether Free Tier is enabled. + :paramtype enable_free_tier: bool + :keyword api_properties: API specific properties. + :paramtype api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties + :keyword enable_analytical_storage: Flag to indicate whether to enable storage analytics. + :paramtype enable_analytical_storage: bool + :keyword analytical_storage_configuration: Analytical storage specific properties. + :paramtype analytical_storage_configuration: + ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration + :keyword create_mode: Enum to indicate the mode of account creation. Possible values include: + "Default", "Restore". Default value: "Default". + :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode + :keyword restore_parameters: Parameters to indicate the information about the restore. + :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.RestoreParameters + :keyword backup_policy: The object representing the policy for taking backups on an account. + :paramtype backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy + :keyword cors: The CORS policy for the Cosmos DB database account. + :paramtype cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] + :keyword network_acl_bypass: Indicates what services are allowed to bypass firewall checks. + Possible values include: "None", "AzureServices". + :paramtype network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass + :keyword network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network + Acl Bypass for the Cosmos DB account. + :paramtype network_acl_bypass_resource_ids: list[str] + :keyword disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be + used exclusively for authentication. + :paramtype disable_local_auth: bool + :keyword capacity: The object that represents all properties related to capacity enforcement on + an account. + :paramtype capacity: ~azure.mgmt.cosmosdb.models.Capacity + """ super(DatabaseAccountGetResults, self).__init__(location=location, tags=tags, **kwargs) self.kind = kind self.identity = identity @@ -2442,9 +3087,9 @@ def __init__( class DatabaseAccountListConnectionStringsResult(msrest.serialization.Model): """The connection strings for the given database account. - :param connection_strings: An array that contains the connection strings for the Cosmos DB + :ivar connection_strings: An array that contains the connection strings for the Cosmos DB account. - :type connection_strings: list[~azure.mgmt.cosmosdb.models.DatabaseAccountConnectionString] + :vartype connection_strings: list[~azure.mgmt.cosmosdb.models.DatabaseAccountConnectionString] """ _attribute_map = { @@ -2457,6 +3102,12 @@ def __init__( connection_strings: Optional[List["DatabaseAccountConnectionString"]] = None, **kwargs ): + """ + :keyword connection_strings: An array that contains the connection strings for the Cosmos DB + account. + :paramtype connection_strings: + list[~azure.mgmt.cosmosdb.models.DatabaseAccountConnectionString] + """ super(DatabaseAccountListConnectionStringsResult, self).__init__(**kwargs) self.connection_strings = connection_strings @@ -2486,6 +3137,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseAccountListReadOnlyKeysResult, self).__init__(**kwargs) self.primary_readonly_master_key = None self.secondary_readonly_master_key = None @@ -2524,6 +3177,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseAccountListKeysResult, self).__init__(**kwargs) self.primary_master_key = None self.secondary_master_key = None @@ -2534,9 +3189,9 @@ class DatabaseAccountRegenerateKeyParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_kind: Required. The access key to regenerate. Possible values include: "primary", + :ivar key_kind: Required. The access key to regenerate. Possible values include: "primary", "secondary", "primaryReadonly", "secondaryReadonly". - :type key_kind: str or ~azure.mgmt.cosmosdb.models.KeyKind + :vartype key_kind: str or ~azure.mgmt.cosmosdb.models.KeyKind """ _validation = { @@ -2553,6 +3208,11 @@ def __init__( key_kind: Union[str, "KeyKind"], **kwargs ): + """ + :keyword key_kind: Required. The access key to regenerate. Possible values include: "primary", + "secondary", "primaryReadonly", "secondaryReadonly". + :paramtype key_kind: str or ~azure.mgmt.cosmosdb.models.KeyKind + """ super(DatabaseAccountRegenerateKeyParameters, self).__init__(**kwargs) self.key_kind = key_kind @@ -2578,6 +3238,8 @@ def __init__( self, **kwargs ): + """ + """ super(DatabaseAccountsListResult, self).__init__(**kwargs) self.value = None @@ -2585,81 +3247,81 @@ def __init__( class DatabaseAccountUpdateParameters(msrest.serialization.Model): """Parameters for patching Azure Cosmos DB database account properties. - :param tags: A set of 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". - :type tags: dict[str, str] - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :param consistency_policy: The consistency policy for the Cosmos DB account. - :type consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy - :param locations: An array that contains the georeplication locations enabled for the Cosmos DB + :ivar tags: A set of 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 location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity + :ivar consistency_policy: The consistency policy for the Cosmos DB account. + :vartype consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy + :ivar locations: An array that contains the georeplication locations enabled for the Cosmos DB account. - :type locations: list[~azure.mgmt.cosmosdb.models.Location] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] - :param is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual + :vartype locations: list[~azure.mgmt.cosmosdb.models.Location] + :ivar ip_rules: List of IpRules. + :vartype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] + :ivar is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual Network ACL rules. - :type is_virtual_network_filter_enabled: bool - :param enable_automatic_failover: Enables automatic failover of the write region in the rare + :vartype is_virtual_network_filter_enabled: bool + :ivar enable_automatic_failover: Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. - :type enable_automatic_failover: bool - :param capabilities: List of Cosmos DB capabilities for the account. - :type capabilities: list[~azure.mgmt.cosmosdb.models.Capability] - :param virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB + :vartype enable_automatic_failover: bool + :ivar capabilities: List of Cosmos DB capabilities for the account. + :vartype capabilities: list[~azure.mgmt.cosmosdb.models.Capability] + :ivar virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB account. - :type virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] - :param enable_multiple_write_locations: Enables the account to write in multiple locations. - :type enable_multiple_write_locations: bool - :param enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* account. - :type enable_cassandra_connector: bool - :param connector_offer: The cassandra connector offer type for the Cosmos DB database C* + :vartype virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] + :ivar enable_multiple_write_locations: Enables the account to write in multiple locations. + :vartype enable_multiple_write_locations: bool + :ivar enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* account. + :vartype enable_cassandra_connector: bool + :ivar connector_offer: The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: "Small". - :type connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer - :param disable_key_based_metadata_write_access: Disable write operations on metadata resources + :vartype connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer + :ivar disable_key_based_metadata_write_access: Disable write operations on metadata resources (databases, containers, throughput) via account keys. - :type disable_key_based_metadata_write_access: bool - :param key_vault_key_uri: The URI of the key vault. - :type key_vault_key_uri: str - :param default_identity: The default identity for accessing key vault used in features like + :vartype disable_key_based_metadata_write_access: bool + :ivar key_vault_key_uri: The URI of the key vault. + :vartype key_vault_key_uri: str + :ivar default_identity: The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. - :type default_identity: str - :param public_network_access: Whether requests from Public Network are allowed. Possible values + :vartype default_identity: str + :ivar public_network_access: Whether requests from Public Network are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess - :param enable_free_tier: Flag to indicate whether Free Tier is enabled. - :type enable_free_tier: bool - :param api_properties: API specific properties. Currently, supported only for MongoDB API. - :type api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties - :param enable_analytical_storage: Flag to indicate whether to enable storage analytics. - :type enable_analytical_storage: bool - :param analytical_storage_configuration: Analytical storage specific properties. - :type analytical_storage_configuration: + :vartype public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess + :ivar enable_free_tier: Flag to indicate whether Free Tier is enabled. + :vartype enable_free_tier: bool + :ivar api_properties: API specific properties. Currently, supported only for MongoDB API. + :vartype api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties + :ivar enable_analytical_storage: Flag to indicate whether to enable storage analytics. + :vartype enable_analytical_storage: bool + :ivar analytical_storage_configuration: Analytical storage specific properties. + :vartype analytical_storage_configuration: ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration - :param backup_policy: The object representing the policy for taking backups on an account. - :type backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy - :param cors: The CORS policy for the Cosmos DB database account. - :type cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] - :param network_acl_bypass: Indicates what services are allowed to bypass firewall checks. + :ivar backup_policy: The object representing the policy for taking backups on an account. + :vartype backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy + :ivar cors: The CORS policy for the Cosmos DB database account. + :vartype cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] + :ivar network_acl_bypass: Indicates what services are allowed to bypass firewall checks. Possible values include: "None", "AzureServices". - :type network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass - :param network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network Acl + :vartype network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass + :ivar network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. - :type network_acl_bypass_resource_ids: list[str] - :param disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be + :vartype network_acl_bypass_resource_ids: list[str] + :ivar disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. - :type disable_local_auth: bool - :param capacity: The object that represents all properties related to capacity enforcement on - an account. - :type capacity: ~azure.mgmt.cosmosdb.models.Capacity + :vartype disable_local_auth: bool + :ivar capacity: The object that represents all properties related to capacity enforcement on an + account. + :vartype capacity: ~azure.mgmt.cosmosdb.models.Capacity """ _attribute_map = { @@ -2724,6 +3386,84 @@ def __init__( capacity: Optional["Capacity"] = None, **kwargs ): + """ + :keyword tags: A set of 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 location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity + :keyword consistency_policy: The consistency policy for the Cosmos DB account. + :paramtype consistency_policy: ~azure.mgmt.cosmosdb.models.ConsistencyPolicy + :keyword locations: An array that contains the georeplication locations enabled for the Cosmos + DB account. + :paramtype locations: list[~azure.mgmt.cosmosdb.models.Location] + :keyword ip_rules: List of IpRules. + :paramtype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] + :keyword is_virtual_network_filter_enabled: Flag to indicate whether to enable/disable Virtual + Network ACL rules. + :paramtype is_virtual_network_filter_enabled: bool + :keyword enable_automatic_failover: Enables automatic failover of the write region in the rare + event that the region is unavailable due to an outage. Automatic failover will result in a new + write region for the account and is chosen based on the failover priorities configured for the + account. + :paramtype enable_automatic_failover: bool + :keyword capabilities: List of Cosmos DB capabilities for the account. + :paramtype capabilities: list[~azure.mgmt.cosmosdb.models.Capability] + :keyword virtual_network_rules: List of Virtual Network ACL rules configured for the Cosmos DB + account. + :paramtype virtual_network_rules: list[~azure.mgmt.cosmosdb.models.VirtualNetworkRule] + :keyword enable_multiple_write_locations: Enables the account to write in multiple locations. + :paramtype enable_multiple_write_locations: bool + :keyword enable_cassandra_connector: Enables the cassandra connector on the Cosmos DB C* + account. + :paramtype enable_cassandra_connector: bool + :keyword connector_offer: The cassandra connector offer type for the Cosmos DB database C* + account. Possible values include: "Small". + :paramtype connector_offer: str or ~azure.mgmt.cosmosdb.models.ConnectorOffer + :keyword disable_key_based_metadata_write_access: Disable write operations on metadata + resources (databases, containers, throughput) via account keys. + :paramtype disable_key_based_metadata_write_access: bool + :keyword key_vault_key_uri: The URI of the key vault. + :paramtype key_vault_key_uri: str + :keyword default_identity: The default identity for accessing key vault used in features like + customer managed keys. The default identity needs to be explicitly set by the users. It can be + "FirstPartyIdentity", "SystemAssignedIdentity" and more. + :paramtype default_identity: str + :keyword public_network_access: Whether requests from Public Network are allowed. Possible + values include: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.cosmosdb.models.PublicNetworkAccess + :keyword enable_free_tier: Flag to indicate whether Free Tier is enabled. + :paramtype enable_free_tier: bool + :keyword api_properties: API specific properties. Currently, supported only for MongoDB API. + :paramtype api_properties: ~azure.mgmt.cosmosdb.models.ApiProperties + :keyword enable_analytical_storage: Flag to indicate whether to enable storage analytics. + :paramtype enable_analytical_storage: bool + :keyword analytical_storage_configuration: Analytical storage specific properties. + :paramtype analytical_storage_configuration: + ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration + :keyword backup_policy: The object representing the policy for taking backups on an account. + :paramtype backup_policy: ~azure.mgmt.cosmosdb.models.BackupPolicy + :keyword cors: The CORS policy for the Cosmos DB database account. + :paramtype cors: list[~azure.mgmt.cosmosdb.models.CorsPolicy] + :keyword network_acl_bypass: Indicates what services are allowed to bypass firewall checks. + Possible values include: "None", "AzureServices". + :paramtype network_acl_bypass: str or ~azure.mgmt.cosmosdb.models.NetworkAclBypass + :keyword network_acl_bypass_resource_ids: An array that contains the Resource Ids for Network + Acl Bypass for the Cosmos DB account. + :paramtype network_acl_bypass_resource_ids: list[str] + :keyword disable_local_auth: Opt-out of local authentication and ensure only MSI and AAD can be + used exclusively for authentication. + :paramtype disable_local_auth: bool + :keyword capacity: The object that represents all properties related to capacity enforcement on + an account. + :paramtype capacity: ~azure.mgmt.cosmosdb.models.Capacity + """ super(DatabaseAccountUpdateParameters, self).__init__(**kwargs) self.tags = tags self.location = location @@ -2757,10 +3497,10 @@ def __init__( class DatabaseRestoreResource(msrest.serialization.Model): """Specific Databases to restore. - :param database_name: The name of the database available for restore. - :type database_name: str - :param collection_names: The names of the collections available for restore. - :type collection_names: list[str] + :ivar database_name: The name of the database available for restore. + :vartype database_name: str + :ivar collection_names: The names of the collections available for restore. + :vartype collection_names: list[str] """ _attribute_map = { @@ -2775,6 +3515,12 @@ def __init__( collection_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword database_name: The name of the database available for restore. + :paramtype database_name: str + :keyword collection_names: The names of the collections available for restore. + :paramtype collection_names: list[str] + """ super(DatabaseRestoreResource, self).__init__(**kwargs) self.database_name = database_name self.collection_names = collection_names @@ -2791,8 +3537,8 @@ class DataCenterResource(ARMProxyResource): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param properties: Properties of a managed Cassandra data center. - :type properties: ~azure.mgmt.cosmosdb.models.DataCenterResourceProperties + :ivar properties: Properties of a managed Cassandra data center. + :vartype properties: ~azure.mgmt.cosmosdb.models.DataCenterResourceProperties """ _validation = { @@ -2814,6 +3560,10 @@ def __init__( properties: Optional["DataCenterResourceProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of a managed Cassandra data center. + :paramtype properties: ~azure.mgmt.cosmosdb.models.DataCenterResourceProperties + """ super(DataCenterResource, self).__init__(**kwargs) self.properties = properties @@ -2823,47 +3573,48 @@ class DataCenterResourceProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param provisioning_state: The status of the resource at the time the operation was called. + :ivar provisioning_state: The status of the resource at the time the operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :type provisioning_state: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraProvisioningState - :param data_center_location: The region this data center should be created in. - :type data_center_location: str - :param delegated_subnet_id: Resource id of a subnet the nodes in this data center should have + :vartype provisioning_state: str or + ~azure.mgmt.cosmosdb.models.ManagedCassandraProvisioningState + :ivar data_center_location: The region this data center should be created in. + :vartype data_center_location: str + :ivar delegated_subnet_id: Resource id of a subnet the nodes in this data center should have their network interfaces connected to. The subnet must be in the same region specified in 'dataCenterLocation' and must be able to route to the subnet specified in the cluster's 'delegatedManagementSubnetId' property. This resource id will be of the form '/subscriptions/:code:``/resourceGroups/:code:``/providers/Microsoft.Network/virtualNetworks/:code:``/subnets/:code:``'. - :type delegated_subnet_id: str - :param node_count: The number of nodes the data center should have. This is the desired number. + :vartype delegated_subnet_id: str + :ivar node_count: The number of nodes the data center should have. This is the desired number. After it is set, it may take some time for the data center to be scaled to match. To monitor the number of nodes and their status, use the fetchNodeStatus method on the cluster. - :type node_count: int + :vartype node_count: int :ivar seed_nodes: IP addresses for seed nodes in this data center. This is for reference. Generally you will want to use the seedNodes property on the cluster, which aggregates the seed nodes from all data centers in the cluster. :vartype seed_nodes: list[~azure.mgmt.cosmosdb.models.SeedNode] - :param base64_encoded_cassandra_yaml_fragment: A fragment of a cassandra.yaml configuration - file to be included in the cassandra.yaml for all nodes in this data center. The fragment - should be Base64 encoded, and only a subset of keys are allowed. - :type base64_encoded_cassandra_yaml_fragment: str - :param managed_disk_customer_key_uri: Key uri to use for encryption of managed disks. Ensure - the system assigned identity of the cluster has been assigned appropriate permissions(key + :ivar base64_encoded_cassandra_yaml_fragment: A fragment of a cassandra.yaml configuration file + to be included in the cassandra.yaml for all nodes in this data center. The fragment should be + Base64 encoded, and only a subset of keys are allowed. + :vartype base64_encoded_cassandra_yaml_fragment: str + :ivar managed_disk_customer_key_uri: Key uri to use for encryption of managed disks. Ensure the + system assigned identity of the cluster has been assigned appropriate permissions(key get/wrap/unwrap permissions) on the key. - :type managed_disk_customer_key_uri: str - :param backup_storage_customer_key_uri: Indicates the Key Uri of the customer key to use for + :vartype managed_disk_customer_key_uri: str + :ivar backup_storage_customer_key_uri: Indicates the Key Uri of the customer key to use for encryption of the backup storage account. - :type backup_storage_customer_key_uri: str - :param sku: Virtual Machine SKU used for data centers. Default value is Standard_DS14_v2. - :type sku: str - :param disk_sku: Disk SKU used for data centers. Default value is P30. - :type disk_sku: str - :param disk_capacity: Number of disk used for data centers. Default value is 4. - :type disk_capacity: int - :param availability_zone: If the azure data center has Availability Zone support, apply it to + :vartype backup_storage_customer_key_uri: str + :ivar sku: Virtual Machine SKU used for data centers. Default value is Standard_DS14_v2. + :vartype sku: str + :ivar disk_sku: Disk SKU used for data centers. Default value is P30. + :vartype disk_sku: str + :ivar disk_capacity: Number of disk used for data centers. Default value is 4. + :vartype disk_capacity: int + :ivar availability_zone: If the azure data center has Availability Zone support, apply it to the Virtual Machine ScaleSet that host the cassandra data center virtual machines. - :type availability_zone: bool + :vartype availability_zone: bool """ _validation = { @@ -2901,6 +3652,46 @@ def __init__( availability_zone: Optional[bool] = None, **kwargs ): + """ + :keyword provisioning_state: The status of the resource at the time the operation was called. + Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :paramtype provisioning_state: str or + ~azure.mgmt.cosmosdb.models.ManagedCassandraProvisioningState + :keyword data_center_location: The region this data center should be created in. + :paramtype data_center_location: str + :keyword delegated_subnet_id: Resource id of a subnet the nodes in this data center should have + their network interfaces connected to. The subnet must be in the same region specified in + 'dataCenterLocation' and must be able to route to the subnet specified in the cluster's + 'delegatedManagementSubnetId' property. This resource id will be of the form + '/subscriptions/:code:``/resourceGroups/:code:``/providers/Microsoft.Network/virtualNetworks/:code:``/subnets/:code:``'. + :paramtype delegated_subnet_id: str + :keyword node_count: The number of nodes the data center should have. This is the desired + number. After it is set, it may take some time for the data center to be scaled to match. To + monitor the number of nodes and their status, use the fetchNodeStatus method on the cluster. + :paramtype node_count: int + :keyword base64_encoded_cassandra_yaml_fragment: A fragment of a cassandra.yaml configuration + file to be included in the cassandra.yaml for all nodes in this data center. The fragment + should be Base64 encoded, and only a subset of keys are allowed. + :paramtype base64_encoded_cassandra_yaml_fragment: str + :keyword managed_disk_customer_key_uri: Key uri to use for encryption of managed disks. Ensure + the system assigned identity of the cluster has been assigned appropriate permissions(key + get/wrap/unwrap permissions) on the key. + :paramtype managed_disk_customer_key_uri: str + :keyword backup_storage_customer_key_uri: Indicates the Key Uri of the customer key to use for + encryption of the backup storage account. + :paramtype backup_storage_customer_key_uri: str + :keyword sku: Virtual Machine SKU used for data centers. Default value is Standard_DS14_v2. + :paramtype sku: str + :keyword disk_sku: Disk SKU used for data centers. Default value is P30. + :paramtype disk_sku: str + :keyword disk_capacity: Number of disk used for data centers. Default value is 4. + :paramtype disk_capacity: int + :keyword availability_zone: If the azure data center has Availability Zone support, apply it to + the Virtual Machine ScaleSet that host the cassandra data center virtual machines. + :paramtype availability_zone: bool + """ super(DataCenterResourceProperties, self).__init__(**kwargs) self.provisioning_state = provisioning_state self.data_center_location = data_center_location @@ -2919,10 +3710,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error Response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -2937,6 +3728,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -2945,9 +3742,9 @@ def __init__( class ExcludedPath(msrest.serialization.Model): """ExcludedPath. - :param path: The path for which the indexing behavior applies to. Index paths typically start + :ivar path: The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*). - :type path: str + :vartype path: str """ _attribute_map = { @@ -2960,6 +3757,11 @@ def __init__( path: Optional[str] = None, **kwargs ): + """ + :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 + """ super(ExcludedPath, self).__init__(**kwargs) self.path = path @@ -2969,8 +3771,8 @@ class FailoverPolicies(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_policies: Required. List of failover policies. - :type failover_policies: list[~azure.mgmt.cosmosdb.models.FailoverPolicy] + :ivar failover_policies: Required. List of failover policies. + :vartype failover_policies: list[~azure.mgmt.cosmosdb.models.FailoverPolicy] """ _validation = { @@ -2987,6 +3789,10 @@ def __init__( failover_policies: List["FailoverPolicy"], **kwargs ): + """ + :keyword failover_policies: Required. List of failover policies. + :paramtype failover_policies: list[~azure.mgmt.cosmosdb.models.FailoverPolicy] + """ super(FailoverPolicies, self).__init__(**kwargs) self.failover_policies = failover_policies @@ -2999,13 +3805,13 @@ class FailoverPolicy(msrest.serialization.Model): :ivar id: The unique identifier of the region in which the database account replicates to. Example: <accountName>-<locationName>. :vartype id: str - :param location_name: The name of the region in which the database account exists. - :type location_name: str - :param failover_priority: The failover priority of the region. A failover priority of 0 + :ivar location_name: The name of the region in which the database account exists. + :vartype location_name: str + :ivar failover_priority: The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. - :type failover_priority: int + :vartype failover_priority: int """ _validation = { @@ -3026,6 +3832,15 @@ def __init__( failover_priority: Optional[int] = None, **kwargs ): + """ + :keyword location_name: The name of the region in which the database account exists. + :paramtype location_name: str + :keyword failover_priority: The failover priority of the region. A failover priority of 0 + indicates a write region. The maximum value for a failover priority = (total number of regions + - 1). Failover priority values must be unique for each of the regions in which the database + account exists. + :paramtype failover_priority: int + """ super(FailoverPolicy, self).__init__(**kwargs) self.id = None self.location_name = location_name @@ -3045,20 +3860,20 @@ class GremlinDatabaseCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a Gremlin database. - :type resource: ~azure.mgmt.cosmosdb.models.GremlinDatabaseResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a Gremlin database. + :vartype resource: ~azure.mgmt.cosmosdb.models.GremlinDatabaseResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -3087,6 +3902,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a Gremlin database. + :paramtype resource: ~azure.mgmt.cosmosdb.models.GremlinDatabaseResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(GremlinDatabaseCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -3095,11 +3926,11 @@ def __init__( class GremlinDatabaseGetPropertiesOptions(OptionsResource): """GremlinDatabaseGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -3114,6 +3945,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(GremlinDatabaseGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -3122,8 +3960,8 @@ class GremlinDatabaseResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB Gremlin database. - :type id: str + :ivar id: Required. Name of the Cosmos DB Gremlin database. + :vartype id: str """ _validation = { @@ -3140,6 +3978,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB Gremlin database. + :paramtype id: str + """ super(GremlinDatabaseResource, self).__init__(**kwargs) self.id = id @@ -3151,8 +3993,8 @@ class GremlinDatabaseGetPropertiesResource(ExtendedResourceProperties, GremlinDa All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB Gremlin database. - :type id: str + :ivar id: Required. Name of the Cosmos DB Gremlin database. + :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. @@ -3182,6 +4024,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB Gremlin database. + :paramtype id: str + """ super(GremlinDatabaseGetPropertiesResource, self).__init__(id=id, **kwargs) self.id = id self.rid = None @@ -3200,19 +4046,19 @@ class GremlinDatabaseGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetPropertiesOptions """ _validation = { @@ -3240,6 +4086,21 @@ def __init__( options: Optional["GremlinDatabaseGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetPropertiesOptions + """ super(GremlinDatabaseGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -3266,6 +4127,8 @@ def __init__( self, **kwargs ): + """ + """ super(GremlinDatabaseListResult, self).__init__(**kwargs) self.value = None @@ -3283,20 +4146,20 @@ class GremlinGraphCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a Gremlin graph. - :type resource: ~azure.mgmt.cosmosdb.models.GremlinGraphResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a Gremlin graph. + :vartype resource: ~azure.mgmt.cosmosdb.models.GremlinGraphResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -3325,6 +4188,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a Gremlin graph. + :paramtype resource: ~azure.mgmt.cosmosdb.models.GremlinGraphResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(GremlinGraphCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -3333,11 +4212,11 @@ def __init__( class GremlinGraphGetPropertiesOptions(OptionsResource): """GremlinGraphGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -3352,6 +4231,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(GremlinGraphGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -3360,21 +4246,21 @@ class GremlinGraphResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB Gremlin graph. - :type id: str - :param indexing_policy: The configuration of the indexing policy. By default, the indexing is + :ivar id: Required. Name of the Cosmos DB Gremlin graph. + :vartype id: str + :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph. - :type indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy - :param partition_key: The configuration of the partition key to be used for partitioning data + :vartype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :ivar partition_key: The configuration of the partition key to be used for partitioning data into multiple partitions. - :type partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey - :param default_ttl: Default time to live. - :type default_ttl: int - :param unique_key_policy: The unique key policy configuration for specifying uniqueness + :vartype partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey + :ivar default_ttl: Default time to live. + :vartype default_ttl: int + :ivar unique_key_policy: The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - :type unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy - :param conflict_resolution_policy: The conflict resolution policy for the graph. - :type conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + :vartype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :ivar conflict_resolution_policy: The conflict resolution policy for the graph. + :vartype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy """ _validation = { @@ -3401,6 +4287,23 @@ def __init__( conflict_resolution_policy: Optional["ConflictResolutionPolicy"] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB Gremlin graph. + :paramtype id: str + :keyword indexing_policy: The configuration of the indexing policy. By default, the indexing is + automatic for all document paths within the graph. + :paramtype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :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 + :keyword unique_key_policy: The unique key policy configuration for specifying uniqueness + constraints on documents in the collection in the Azure Cosmos DB service. + :paramtype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :keyword conflict_resolution_policy: The conflict resolution policy for the graph. + :paramtype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + """ super(GremlinGraphResource, self).__init__(**kwargs) self.id = id self.indexing_policy = indexing_policy @@ -3417,21 +4320,21 @@ class GremlinGraphGetPropertiesResource(ExtendedResourceProperties, GremlinGraph All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB Gremlin graph. - :type id: str - :param indexing_policy: The configuration of the indexing policy. By default, the indexing is + :ivar id: Required. Name of the Cosmos DB Gremlin graph. + :vartype id: str + :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph. - :type indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy - :param partition_key: The configuration of the partition key to be used for partitioning data + :vartype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :ivar partition_key: The configuration of the partition key to be used for partitioning data into multiple partitions. - :type partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey - :param default_ttl: Default time to live. - :type default_ttl: int - :param unique_key_policy: The unique key policy configuration for specifying uniqueness + :vartype partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey + :ivar default_ttl: Default time to live. + :vartype default_ttl: int + :ivar unique_key_policy: The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - :type unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy - :param conflict_resolution_policy: The conflict resolution policy for the graph. - :type conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + :vartype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :ivar conflict_resolution_policy: The conflict resolution policy for the graph. + :vartype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy :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. @@ -3471,6 +4374,23 @@ def __init__( conflict_resolution_policy: Optional["ConflictResolutionPolicy"] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB Gremlin graph. + :paramtype id: str + :keyword indexing_policy: The configuration of the indexing policy. By default, the indexing is + automatic for all document paths within the graph. + :paramtype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :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 + :keyword unique_key_policy: The unique key policy configuration for specifying uniqueness + constraints on documents in the collection in the Azure Cosmos DB service. + :paramtype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :keyword conflict_resolution_policy: The conflict resolution policy for the graph. + :paramtype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + """ super(GremlinGraphGetPropertiesResource, self).__init__(id=id, indexing_policy=indexing_policy, partition_key=partition_key, default_ttl=default_ttl, unique_key_policy=unique_key_policy, conflict_resolution_policy=conflict_resolution_policy, **kwargs) self.id = id self.indexing_policy = indexing_policy @@ -3494,19 +4414,19 @@ class GremlinGraphGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.GremlinGraphGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.GremlinGraphGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.GremlinGraphGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.GremlinGraphGetPropertiesOptions """ _validation = { @@ -3534,6 +4454,21 @@ def __init__( options: Optional["GremlinGraphGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.GremlinGraphGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.GremlinGraphGetPropertiesOptions + """ super(GremlinGraphGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -3560,6 +4495,8 @@ def __init__( self, **kwargs ): + """ + """ super(GremlinGraphListResult, self).__init__(**kwargs) self.value = None @@ -3567,11 +4504,11 @@ def __init__( class IncludedPath(msrest.serialization.Model): """The paths that are included in indexing. - :param path: The path for which the indexing behavior applies to. Index paths typically start + :ivar path: The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*). - :type path: str - :param indexes: List of indexes for this path. - :type indexes: list[~azure.mgmt.cosmosdb.models.Indexes] + :vartype path: str + :ivar indexes: List of indexes for this path. + :vartype indexes: list[~azure.mgmt.cosmosdb.models.Indexes] """ _attribute_map = { @@ -3586,6 +4523,13 @@ def __init__( indexes: Optional[List["Indexes"]] = None, **kwargs ): + """ + :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 indexes: List of indexes for this path. + :paramtype indexes: list[~azure.mgmt.cosmosdb.models.Indexes] + """ super(IncludedPath, self).__init__(**kwargs) self.path = path self.indexes = indexes @@ -3594,15 +4538,15 @@ def __init__( class Indexes(msrest.serialization.Model): """The indexes for the path. - :param data_type: The datatype for which the indexing behavior is applied to. Possible values + :ivar data_type: The datatype for which the indexing behavior is applied to. Possible values include: "String", "Number", "Point", "Polygon", "LineString", "MultiPolygon". Default value: "String". - :type data_type: str or ~azure.mgmt.cosmosdb.models.DataType - :param precision: The precision of the index. -1 is maximum precision. - :type precision: int - :param kind: Indicates the type of index. Possible values include: "Hash", "Range", "Spatial". + :vartype data_type: str or ~azure.mgmt.cosmosdb.models.DataType + :ivar precision: The precision of the index. -1 is maximum precision. + :vartype precision: int + :ivar kind: Indicates the type of index. Possible values include: "Hash", "Range", "Spatial". Default value: "Hash". - :type kind: str or ~azure.mgmt.cosmosdb.models.IndexKind + :vartype kind: str or ~azure.mgmt.cosmosdb.models.IndexKind """ _attribute_map = { @@ -3619,6 +4563,17 @@ def __init__( kind: Optional[Union[str, "IndexKind"]] = "Hash", **kwargs ): + """ + :keyword data_type: The datatype for which the indexing behavior is applied to. Possible values + include: "String", "Number", "Point", "Polygon", "LineString", "MultiPolygon". Default value: + "String". + :paramtype data_type: str or ~azure.mgmt.cosmosdb.models.DataType + :keyword precision: The precision of the index. -1 is maximum precision. + :paramtype precision: int + :keyword kind: Indicates the type of index. Possible values include: "Hash", "Range", + "Spatial". Default value: "Hash". + :paramtype kind: str or ~azure.mgmt.cosmosdb.models.IndexKind + """ super(Indexes, self).__init__(**kwargs) self.data_type = data_type self.precision = precision @@ -3628,19 +4583,19 @@ def __init__( class IndexingPolicy(msrest.serialization.Model): """Cosmos DB indexing policy. - :param automatic: Indicates if the indexing policy is automatic. - :type automatic: bool - :param indexing_mode: Indicates the indexing mode. Possible values include: "consistent", + :ivar automatic: Indicates if the indexing policy is automatic. + :vartype automatic: bool + :ivar indexing_mode: Indicates the indexing mode. Possible values include: "consistent", "lazy", "none". Default value: "consistent". - :type indexing_mode: str or ~azure.mgmt.cosmosdb.models.IndexingMode - :param included_paths: List of paths to include in the indexing. - :type included_paths: list[~azure.mgmt.cosmosdb.models.IncludedPath] - :param excluded_paths: List of paths to exclude from indexing. - :type excluded_paths: list[~azure.mgmt.cosmosdb.models.ExcludedPath] - :param composite_indexes: List of composite path list. - :type composite_indexes: list[list[~azure.mgmt.cosmosdb.models.CompositePath]] - :param spatial_indexes: List of spatial specifics. - :type spatial_indexes: list[~azure.mgmt.cosmosdb.models.SpatialSpec] + :vartype indexing_mode: str or ~azure.mgmt.cosmosdb.models.IndexingMode + :ivar included_paths: List of paths to include in the indexing. + :vartype included_paths: list[~azure.mgmt.cosmosdb.models.IncludedPath] + :ivar excluded_paths: List of paths to exclude from indexing. + :vartype excluded_paths: list[~azure.mgmt.cosmosdb.models.ExcludedPath] + :ivar composite_indexes: List of composite path list. + :vartype composite_indexes: list[list[~azure.mgmt.cosmosdb.models.CompositePath]] + :ivar spatial_indexes: List of spatial specifics. + :vartype spatial_indexes: list[~azure.mgmt.cosmosdb.models.SpatialSpec] """ _attribute_map = { @@ -3663,6 +4618,21 @@ def __init__( spatial_indexes: Optional[List["SpatialSpec"]] = None, **kwargs ): + """ + :keyword automatic: Indicates if the indexing policy is automatic. + :paramtype automatic: bool + :keyword indexing_mode: Indicates the indexing mode. Possible values include: "consistent", + "lazy", "none". Default value: "consistent". + :paramtype indexing_mode: str or ~azure.mgmt.cosmosdb.models.IndexingMode + :keyword included_paths: List of paths to include in the indexing. + :paramtype included_paths: list[~azure.mgmt.cosmosdb.models.IncludedPath] + :keyword excluded_paths: List of paths to exclude from indexing. + :paramtype excluded_paths: list[~azure.mgmt.cosmosdb.models.ExcludedPath] + :keyword composite_indexes: List of composite path list. + :paramtype composite_indexes: list[list[~azure.mgmt.cosmosdb.models.CompositePath]] + :keyword spatial_indexes: List of spatial specifics. + :paramtype spatial_indexes: list[~azure.mgmt.cosmosdb.models.SpatialSpec] + """ super(IndexingPolicy, self).__init__(**kwargs) self.automatic = automatic self.indexing_mode = indexing_mode @@ -3675,12 +4645,11 @@ def __init__( class IpAddressOrRange(msrest.serialization.Model): """IpAddressOrRange object. - :param ip_address_or_range: A single IPv4 address or a single IPv4 address range in CIDR - format. Provided IPs must be well-formatted and cannot be contained in one of the following - ranges: 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, since these are not - enforceable by the IP address filter. Example of valid inputs: “23.40.210.245” or - “23.40.210.0/8”. - :type ip_address_or_range: str + :ivar ip_address_or_range: A single IPv4 address or a single IPv4 address range in CIDR format. + Provided IPs must be well-formatted and cannot be contained in one of the following ranges: + 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, since these are not enforceable by + the IP address filter. Example of valid inputs: “23.40.210.245” or “23.40.210.0/8”. + :vartype ip_address_or_range: str """ _attribute_map = { @@ -3693,6 +4662,14 @@ def __init__( ip_address_or_range: Optional[str] = None, **kwargs ): + """ + :keyword ip_address_or_range: A single IPv4 address or a single IPv4 address range in CIDR + format. Provided IPs must be well-formatted and cannot be contained in one of the following + ranges: 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, since these are not + enforceable by the IP address filter. Example of valid inputs: “23.40.210.245” or + “23.40.210.0/8”. + :paramtype ip_address_or_range: str + """ super(IpAddressOrRange, self).__init__(**kwargs) self.ip_address_or_range = ip_address_or_range @@ -3700,8 +4677,8 @@ def __init__( class ListClusters(msrest.serialization.Model): """List of managed Cassandra clusters. - :param value: Container for the array of clusters. - :type value: list[~azure.mgmt.cosmosdb.models.ClusterResource] + :ivar value: Container for the array of clusters. + :vartype value: list[~azure.mgmt.cosmosdb.models.ClusterResource] """ _attribute_map = { @@ -3714,6 +4691,10 @@ def __init__( value: Optional[List["ClusterResource"]] = None, **kwargs ): + """ + :keyword value: Container for the array of clusters. + :paramtype value: list[~azure.mgmt.cosmosdb.models.ClusterResource] + """ super(ListClusters, self).__init__(**kwargs) self.value = value @@ -3739,6 +4720,8 @@ def __init__( self, **kwargs ): + """ + """ super(ListDataCenters, self).__init__(**kwargs) self.value = None @@ -3751,8 +4734,8 @@ class Location(msrest.serialization.Model): :ivar id: The unique identifier of the region within the database account. Example: <accountName>-<locationName>. :vartype id: str - :param location_name: The name of the region. - :type location_name: str + :ivar location_name: The name of the region. + :vartype location_name: str :ivar document_endpoint: The connection endpoint for the specific region. Example: https://<accountName>-<locationName>.documents.azure.com:443/. :vartype document_endpoint: str @@ -3764,14 +4747,14 @@ class Location(msrest.serialization.Model): account is being deleted. 'Failed' – the Cosmos DB account failed creation. 'DeletionFailed' – the Cosmos DB account deletion failed. :vartype provisioning_state: str - :param failover_priority: The failover priority of the region. A failover priority of 0 + :ivar failover_priority: The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. - :type failover_priority: int - :param is_zone_redundant: Flag to indicate whether or not this region is an AvailabilityZone + :vartype failover_priority: int + :ivar is_zone_redundant: Flag to indicate whether or not this region is an AvailabilityZone region. - :type is_zone_redundant: bool + :vartype is_zone_redundant: bool """ _validation = { @@ -3798,6 +4781,18 @@ def __init__( is_zone_redundant: Optional[bool] = None, **kwargs ): + """ + :keyword location_name: The name of the region. + :paramtype location_name: str + :keyword failover_priority: The failover priority of the region. A failover priority of 0 + indicates a write region. The maximum value for a failover priority = (total number of regions + - 1). Failover priority values must be unique for each of the regions in which the database + account exists. + :paramtype failover_priority: int + :keyword is_zone_redundant: Flag to indicate whether or not this region is an AvailabilityZone + region. + :paramtype is_zone_redundant: bool + """ super(Location, self).__init__(**kwargs) self.id = None self.location_name = location_name @@ -3818,8 +4813,8 @@ class LocationGetResult(ARMProxyResource): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param properties: Cosmos DB location metadata. - :type properties: ~azure.mgmt.cosmosdb.models.LocationProperties + :ivar properties: Cosmos DB location metadata. + :vartype properties: ~azure.mgmt.cosmosdb.models.LocationProperties """ _validation = { @@ -3841,6 +4836,10 @@ def __init__( properties: Optional["LocationProperties"] = None, **kwargs ): + """ + :keyword properties: Cosmos DB location metadata. + :paramtype properties: ~azure.mgmt.cosmosdb.models.LocationProperties + """ super(LocationGetResult, self).__init__(**kwargs) self.properties = properties @@ -3866,6 +4865,8 @@ def __init__( self, **kwargs ): + """ + """ super(LocationListResult, self).__init__(**kwargs) self.value = None @@ -3901,6 +4902,8 @@ def __init__( self, **kwargs ): + """ + """ super(LocationProperties, self).__init__(**kwargs) self.supports_availability_zone = None self.is_residency_restricted = None @@ -3916,8 +4919,8 @@ class ManagedCassandraManagedServiceIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant id of the resource. :vartype tenant_id: str - :param type: The type of the resource. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraResourceIdentityType + :ivar type: The type of the resource. Possible values include: "SystemAssigned", "None". + :vartype type: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraResourceIdentityType """ _validation = { @@ -3937,6 +4940,10 @@ def __init__( type: Optional[Union[str, "ManagedCassandraResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The type of the resource. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraResourceIdentityType + """ super(ManagedCassandraManagedServiceIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -3946,12 +4953,12 @@ def __init__( class ManagedCassandraReaperStatus(msrest.serialization.Model): """ManagedCassandraReaperStatus. - :param healthy: - :type healthy: bool - :param repair_run_ids: Dictionary of :code:``. - :type repair_run_ids: dict[str, str] - :param repair_schedules: Dictionary of :code:``. - :type repair_schedules: dict[str, str] + :ivar healthy: + :vartype healthy: bool + :ivar repair_run_ids: Dictionary of :code:``. + :vartype repair_run_ids: dict[str, str] + :ivar repair_schedules: Dictionary of :code:``. + :vartype repair_schedules: dict[str, str] """ _attribute_map = { @@ -3968,6 +4975,14 @@ def __init__( repair_schedules: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword healthy: + :paramtype healthy: bool + :keyword repair_run_ids: Dictionary of :code:``. + :paramtype repair_run_ids: dict[str, str] + :keyword repair_schedules: Dictionary of :code:``. + :paramtype repair_schedules: dict[str, str] + """ super(ManagedCassandraReaperStatus, self).__init__(**kwargs) self.healthy = healthy self.repair_run_ids = repair_run_ids @@ -3985,15 +5000,15 @@ class ManagedServiceIdentity(msrest.serialization.Model): :ivar tenant_id: The tenant id of the system assigned identity. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :param type: The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' + :ivar type: The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned", "None". - :type type: str or ~azure.mgmt.cosmosdb.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with resource. The user + :vartype type: str or ~azure.mgmt.cosmosdb.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.cosmosdb.models.Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -4016,6 +5031,18 @@ def __init__( user_assigned_identities: Optional[Dict[str, "Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, **kwargs ): + """ + :keyword type: The type of identity used for the resource. The type + 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user + assigned identities. The type 'None' will remove any identities from the service. Possible + values include: "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.cosmosdb.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with resource. The + 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.Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(ManagedServiceIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -4065,6 +5092,8 @@ def __init__( self, **kwargs ): + """ + """ super(Metric, self).__init__(**kwargs) self.start_time = None self.end_time = None @@ -4099,6 +5128,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = None self.retention = None @@ -4143,6 +5174,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricDefinition, self).__init__(**kwargs) self.metric_availabilities = None self.primary_aggregation_type = None @@ -4172,6 +5205,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricDefinitionsListResult, self).__init__(**kwargs) self.value = None @@ -4197,6 +5232,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricListResult, self).__init__(**kwargs) self.value = None @@ -4226,6 +5263,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricName, self).__init__(**kwargs) self.value = None self.localized_value = None @@ -4272,6 +5311,8 @@ def __init__( self, **kwargs ): + """ + """ super(MetricValue, self).__init__(**kwargs) self.count = None self.average = None @@ -4294,20 +5335,20 @@ class MongoDBCollectionCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a MongoDB collection. - :type resource: ~azure.mgmt.cosmosdb.models.MongoDBCollectionResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a MongoDB collection. + :vartype resource: ~azure.mgmt.cosmosdb.models.MongoDBCollectionResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -4336,6 +5377,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a MongoDB collection. + :paramtype resource: ~azure.mgmt.cosmosdb.models.MongoDBCollectionResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(MongoDBCollectionCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -4344,11 +5401,11 @@ def __init__( class MongoDBCollectionGetPropertiesOptions(OptionsResource): """MongoDBCollectionGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -4363,6 +5420,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(MongoDBCollectionGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -4371,14 +5435,14 @@ class MongoDBCollectionResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB MongoDB collection. - :type id: str - :param shard_key: A key-value pair of shard keys to be applied for the request. - :type shard_key: dict[str, str] - :param indexes: List of index keys. - :type indexes: list[~azure.mgmt.cosmosdb.models.MongoIndex] - :param analytical_storage_ttl: Analytical TTL. - :type analytical_storage_ttl: int + :ivar id: Required. Name of the Cosmos DB MongoDB collection. + :vartype id: str + :ivar shard_key: A key-value pair of shard keys to be applied for the request. + :vartype shard_key: dict[str, str] + :ivar indexes: List of index keys. + :vartype indexes: list[~azure.mgmt.cosmosdb.models.MongoIndex] + :ivar analytical_storage_ttl: Analytical TTL. + :vartype analytical_storage_ttl: int """ _validation = { @@ -4401,6 +5465,16 @@ def __init__( analytical_storage_ttl: Optional[int] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB MongoDB collection. + :paramtype id: str + :keyword shard_key: A key-value pair of shard keys to be applied for the request. + :paramtype shard_key: dict[str, str] + :keyword indexes: List of index keys. + :paramtype indexes: list[~azure.mgmt.cosmosdb.models.MongoIndex] + :keyword analytical_storage_ttl: Analytical TTL. + :paramtype analytical_storage_ttl: int + """ super(MongoDBCollectionResource, self).__init__(**kwargs) self.id = id self.shard_key = shard_key @@ -4415,14 +5489,14 @@ class MongoDBCollectionGetPropertiesResource(ExtendedResourceProperties, MongoDB All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB MongoDB collection. - :type id: str - :param shard_key: A key-value pair of shard keys to be applied for the request. - :type shard_key: dict[str, str] - :param indexes: List of index keys. - :type indexes: list[~azure.mgmt.cosmosdb.models.MongoIndex] - :param analytical_storage_ttl: Analytical TTL. - :type analytical_storage_ttl: int + :ivar id: Required. Name of the Cosmos DB MongoDB collection. + :vartype id: str + :ivar shard_key: A key-value pair of shard keys to be applied for the request. + :vartype shard_key: dict[str, str] + :ivar indexes: List of index keys. + :vartype indexes: list[~azure.mgmt.cosmosdb.models.MongoIndex] + :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. @@ -4458,6 +5532,16 @@ def __init__( analytical_storage_ttl: Optional[int] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB MongoDB collection. + :paramtype id: str + :keyword shard_key: A key-value pair of shard keys to be applied for the request. + :paramtype shard_key: dict[str, str] + :keyword indexes: List of index keys. + :paramtype indexes: list[~azure.mgmt.cosmosdb.models.MongoIndex] + :keyword analytical_storage_ttl: Analytical TTL. + :paramtype analytical_storage_ttl: int + """ super(MongoDBCollectionGetPropertiesResource, self).__init__(id=id, shard_key=shard_key, indexes=indexes, analytical_storage_ttl=analytical_storage_ttl, **kwargs) self.id = id self.shard_key = shard_key @@ -4479,19 +5563,19 @@ class MongoDBCollectionGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetPropertiesOptions """ _validation = { @@ -4519,6 +5603,21 @@ def __init__( options: Optional["MongoDBCollectionGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetPropertiesOptions + """ super(MongoDBCollectionGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -4545,6 +5644,8 @@ def __init__( self, **kwargs ): + """ + """ super(MongoDBCollectionListResult, self).__init__(**kwargs) self.value = None @@ -4562,20 +5663,20 @@ class MongoDBDatabaseCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a MongoDB database. - :type resource: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a MongoDB database. + :vartype resource: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -4604,6 +5705,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a MongoDB database. + :paramtype resource: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(MongoDBDatabaseCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -4612,11 +5729,11 @@ def __init__( class MongoDBDatabaseGetPropertiesOptions(OptionsResource): """MongoDBDatabaseGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -4631,6 +5748,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(MongoDBDatabaseGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -4639,8 +5763,8 @@ class MongoDBDatabaseResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB MongoDB database. - :type id: str + :ivar id: Required. Name of the Cosmos DB MongoDB database. + :vartype id: str """ _validation = { @@ -4657,6 +5781,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB MongoDB database. + :paramtype id: str + """ super(MongoDBDatabaseResource, self).__init__(**kwargs) self.id = id @@ -4668,8 +5796,8 @@ class MongoDBDatabaseGetPropertiesResource(ExtendedResourceProperties, MongoDBDa All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB MongoDB database. - :type id: str + :ivar id: Required. Name of the Cosmos DB MongoDB database. + :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. @@ -4699,6 +5827,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB MongoDB database. + :paramtype id: str + """ super(MongoDBDatabaseGetPropertiesResource, self).__init__(id=id, **kwargs) self.id = id self.rid = None @@ -4717,19 +5849,19 @@ class MongoDBDatabaseGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetPropertiesOptions """ _validation = { @@ -4757,6 +5889,21 @@ def __init__( options: Optional["MongoDBDatabaseGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetPropertiesOptions + """ super(MongoDBDatabaseGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -4783,6 +5930,8 @@ def __init__( self, **kwargs ): + """ + """ super(MongoDBDatabaseListResult, self).__init__(**kwargs) self.value = None @@ -4790,10 +5939,10 @@ def __init__( class MongoIndex(msrest.serialization.Model): """Cosmos DB MongoDB collection index key. - :param key: Cosmos DB MongoDB collection index keys. - :type key: ~azure.mgmt.cosmosdb.models.MongoIndexKeys - :param options: Cosmos DB MongoDB collection index key options. - :type options: ~azure.mgmt.cosmosdb.models.MongoIndexOptions + :ivar key: Cosmos DB MongoDB collection index keys. + :vartype key: ~azure.mgmt.cosmosdb.models.MongoIndexKeys + :ivar options: Cosmos DB MongoDB collection index key options. + :vartype options: ~azure.mgmt.cosmosdb.models.MongoIndexOptions """ _attribute_map = { @@ -4808,6 +5957,12 @@ def __init__( options: Optional["MongoIndexOptions"] = None, **kwargs ): + """ + :keyword key: Cosmos DB MongoDB collection index keys. + :paramtype key: ~azure.mgmt.cosmosdb.models.MongoIndexKeys + :keyword options: Cosmos DB MongoDB collection index key options. + :paramtype options: ~azure.mgmt.cosmosdb.models.MongoIndexOptions + """ super(MongoIndex, self).__init__(**kwargs) self.key = key self.options = options @@ -4816,8 +5971,8 @@ def __init__( class MongoIndexKeys(msrest.serialization.Model): """Cosmos DB MongoDB collection resource object. - :param keys: List of keys for each MongoDB collection in the Azure Cosmos DB service. - :type keys: list[str] + :ivar keys: List of keys for each MongoDB collection in the Azure Cosmos DB service. + :vartype keys: list[str] """ _attribute_map = { @@ -4830,6 +5985,10 @@ def __init__( keys: Optional[List[str]] = None, **kwargs ): + """ + :keyword keys: List of keys for each MongoDB collection in the Azure Cosmos DB service. + :paramtype keys: list[str] + """ super(MongoIndexKeys, self).__init__(**kwargs) self.keys = keys @@ -4837,10 +5996,10 @@ def __init__( class MongoIndexOptions(msrest.serialization.Model): """Cosmos DB MongoDB collection index options. - :param expire_after_seconds: Expire after seconds. - :type expire_after_seconds: int - :param unique: Is unique or not. - :type unique: bool + :ivar expire_after_seconds: Expire after seconds. + :vartype expire_after_seconds: int + :ivar unique: Is unique or not. + :vartype unique: bool """ _attribute_map = { @@ -4855,6 +6014,12 @@ def __init__( unique: Optional[bool] = None, **kwargs ): + """ + :keyword expire_after_seconds: Expire after seconds. + :paramtype expire_after_seconds: int + :keyword unique: Is unique or not. + :paramtype unique: bool + """ super(MongoIndexOptions, self).__init__(**kwargs) self.expire_after_seconds = expire_after_seconds self.unique = unique @@ -4898,6 +6063,8 @@ def __init__( self, **kwargs ): + """ + """ super(NotebookWorkspace, self).__init__(**kwargs) self.notebook_server_endpoint = None self.status = None @@ -4929,6 +6096,8 @@ def __init__( self, **kwargs ): + """ + """ super(NotebookWorkspaceConnectionInfoResult, self).__init__(**kwargs) self.auth_token = None self.notebook_server_endpoint = None @@ -4963,14 +6132,16 @@ def __init__( self, **kwargs ): + """ + """ super(NotebookWorkspaceCreateUpdateParameters, self).__init__(**kwargs) class NotebookWorkspaceListResult(msrest.serialization.Model): """A list of notebook workspace resources. - :param value: Array of notebook workspace resources. - :type value: list[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :ivar value: Array of notebook workspace resources. + :vartype value: list[~azure.mgmt.cosmosdb.models.NotebookWorkspace] """ _attribute_map = { @@ -4983,6 +6154,10 @@ def __init__( value: Optional[List["NotebookWorkspace"]] = None, **kwargs ): + """ + :keyword value: Array of notebook workspace resources. + :paramtype value: list[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + """ super(NotebookWorkspaceListResult, self).__init__(**kwargs) self.value = value @@ -4990,10 +6165,10 @@ def __init__( class Operation(msrest.serialization.Model): """REST API operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.cosmosdb.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.cosmosdb.models.OperationDisplay """ _attribute_map = { @@ -5008,6 +6183,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.cosmosdb.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -5016,14 +6197,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.ResourceProvider. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of operation. - :type description: str + :ivar provider: Service provider: Microsoft.ResourceProvider. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of operation. + :vartype description: str """ _attribute_map = { @@ -5042,6 +6223,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.ResourceProvider. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -5052,10 +6243,10 @@ def __init__( class OperationListResult(msrest.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. - :param value: List of operations supported by the Resource Provider. - :type value: list[~azure.mgmt.cosmosdb.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of operations supported by the Resource Provider. + :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 """ _attribute_map = { @@ -5070,6 +6261,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of operations supported by the Resource Provider. + :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 + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -5126,6 +6323,8 @@ def __init__( self, **kwargs ): + """ + """ super(PartitionMetric, self).__init__(**kwargs) self.partition_id = None self.partition_key_range_id = None @@ -5152,6 +6351,8 @@ def __init__( self, **kwargs ): + """ + """ super(PartitionMetricListResult, self).__init__(**kwargs) self.value = None @@ -5194,6 +6395,8 @@ def __init__( self, **kwargs ): + """ + """ super(Usage, self).__init__(**kwargs) self.unit = None self.name = None @@ -5248,6 +6451,8 @@ def __init__( self, **kwargs ): + """ + """ super(PartitionUsage, self).__init__(**kwargs) self.partition_id = None self.partition_key_range_id = None @@ -5275,6 +6480,8 @@ def __init__( self, **kwargs ): + """ + """ super(PartitionUsagesResult, self).__init__(**kwargs) self.value = None @@ -5321,6 +6528,8 @@ def __init__( self, **kwargs ): + """ + """ super(PercentileMetric, self).__init__(**kwargs) self.start_time = None self.end_time = None @@ -5351,6 +6560,8 @@ def __init__( self, **kwargs ): + """ + """ super(PercentileMetricListResult, self).__init__(**kwargs) self.value = None @@ -5424,6 +6635,8 @@ def __init__( self, **kwargs ): + """ + """ super(PercentileMetricValue, self).__init__(**kwargs) self.p10 = None self.p25 = None @@ -5439,14 +6652,14 @@ class PeriodicModeBackupPolicy(BackupPolicy): All required parameters must be populated in order to send to Azure. - :param type: Required. Describes the mode of backups.Constant filled by server. Possible - values include: "Periodic", "Continuous". - :type type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType - :param migration_state: The object representing the state of the migration between the backup + :ivar type: Required. Describes the mode of backups.Constant filled by server. Possible values + include: "Periodic", "Continuous". + :vartype type: str or ~azure.mgmt.cosmosdb.models.BackupPolicyType + :ivar migration_state: The object representing the state of the migration between the backup policies. - :type migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState - :param periodic_mode_properties: Configuration values for periodic mode backup. - :type periodic_mode_properties: ~azure.mgmt.cosmosdb.models.PeriodicModeProperties + :vartype migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState + :ivar periodic_mode_properties: Configuration values for periodic mode backup. + :vartype periodic_mode_properties: ~azure.mgmt.cosmosdb.models.PeriodicModeProperties """ _validation = { @@ -5466,6 +6679,13 @@ def __init__( periodic_mode_properties: Optional["PeriodicModeProperties"] = None, **kwargs ): + """ + :keyword migration_state: The object representing the state of the migration between the backup + policies. + :paramtype migration_state: ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationState + :keyword periodic_mode_properties: Configuration values for periodic mode backup. + :paramtype periodic_mode_properties: ~azure.mgmt.cosmosdb.models.PeriodicModeProperties + """ super(PeriodicModeBackupPolicy, self).__init__(migration_state=migration_state, **kwargs) self.type = 'Periodic' # type: str self.periodic_mode_properties = periodic_mode_properties @@ -5474,15 +6694,15 @@ def __init__( class PeriodicModeProperties(msrest.serialization.Model): """Configuration values for periodic mode backup. - :param backup_interval_in_minutes: An integer representing the interval in minutes between two + :ivar backup_interval_in_minutes: An integer representing the interval in minutes between two backups. - :type backup_interval_in_minutes: int - :param backup_retention_interval_in_hours: An integer representing the time (in hours) that - each backup is retained. - :type backup_retention_interval_in_hours: int - :param backup_storage_redundancy: Enum to indicate type of backup residency. Possible values + :vartype backup_interval_in_minutes: int + :ivar backup_retention_interval_in_hours: An integer representing the time (in hours) that each + backup is retained. + :vartype backup_retention_interval_in_hours: int + :ivar backup_storage_redundancy: Enum to indicate type of backup residency. Possible values include: "Geo", "Local", "Zone". - :type backup_storage_redundancy: str or ~azure.mgmt.cosmosdb.models.BackupStorageRedundancy + :vartype backup_storage_redundancy: str or ~azure.mgmt.cosmosdb.models.BackupStorageRedundancy """ _validation = { @@ -5504,6 +6724,18 @@ def __init__( backup_storage_redundancy: Optional[Union[str, "BackupStorageRedundancy"]] = None, **kwargs ): + """ + :keyword backup_interval_in_minutes: An integer representing the interval in minutes between + two backups. + :paramtype backup_interval_in_minutes: int + :keyword backup_retention_interval_in_hours: An integer representing the time (in hours) that + each backup is retained. + :paramtype backup_retention_interval_in_hours: int + :keyword backup_storage_redundancy: Enum to indicate type of backup residency. Possible values + include: "Geo", "Local", "Zone". + :paramtype backup_storage_redundancy: str or + ~azure.mgmt.cosmosdb.models.BackupStorageRedundancy + """ super(PeriodicModeProperties, self).__init__(**kwargs) self.backup_interval_in_minutes = backup_interval_in_minutes self.backup_retention_interval_in_hours = backup_retention_interval_in_hours @@ -5513,10 +6745,10 @@ def __init__( class Permission(msrest.serialization.Model): """The set of data plane operations permitted through this Role Definition. - :param data_actions: An array of data actions that are allowed. - :type data_actions: list[str] - :param not_data_actions: An array of data actions that are denied. - :type not_data_actions: list[str] + :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 = { @@ -5531,6 +6763,12 @@ def __init__( not_data_actions: Optional[List[str]] = None, **kwargs ): + """ + :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(Permission, self).__init__(**kwargs) self.data_actions = data_actions self.not_data_actions = not_data_actions @@ -5567,6 +6805,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -5604,6 +6844,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) @@ -5620,16 +6862,16 @@ class PrivateEndpointConnection(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~azure.mgmt.cosmosdb.models.PrivateEndpointProperty - :param private_link_service_connection_state: Connection State of the Private Endpoint + :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. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.cosmosdb.models.PrivateLinkServiceConnectionStateProperty - :param group_id: Group id of the private endpoint. - :type group_id: str - :param provisioning_state: Provisioning state of the private endpoint. - :type provisioning_state: str + :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 = { @@ -5657,6 +6899,18 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: ~azure.mgmt.cosmosdb.models.PrivateEndpointProperty + :keyword private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.cosmosdb.models.PrivateLinkServiceConnectionStateProperty + :keyword group_id: Group id of the private endpoint. + :paramtype group_id: str + :keyword provisioning_state: Provisioning state of the private endpoint. + :paramtype provisioning_state: str + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -5667,8 +6921,8 @@ def __init__( class PrivateEndpointConnectionListResult(msrest.serialization.Model): """A list of private endpoint connections. - :param value: Array of private endpoint connections. - :type value: list[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] """ _attribute_map = { @@ -5681,6 +6935,10 @@ def __init__( value: Optional[List["PrivateEndpointConnection"]] = None, **kwargs ): + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = value @@ -5688,8 +6946,8 @@ def __init__( class PrivateEndpointProperty(msrest.serialization.Model): """Private endpoint which the connection belongs to. - :param id: Resource id of the private endpoint. - :type id: str + :ivar id: Resource id of the private endpoint. + :vartype id: str """ _attribute_map = { @@ -5702,6 +6960,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource id of the private endpoint. + :paramtype id: str + """ super(PrivateEndpointProperty, self).__init__(**kwargs) self.id = id @@ -5747,6 +7009,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResource, self).__init__(**kwargs) self.group_id = None self.required_members = None @@ -5756,8 +7020,8 @@ def __init__( class PrivateLinkResourceListResult(msrest.serialization.Model): """A list of private link resources. - :param value: Array of private link resources. - :type value: list[~azure.mgmt.cosmosdb.models.PrivateLinkResource] + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.cosmosdb.models.PrivateLinkResource] """ _attribute_map = { @@ -5770,6 +7034,10 @@ def __init__( value: Optional[List["PrivateLinkResource"]] = None, **kwargs ): + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.cosmosdb.models.PrivateLinkResource] + """ super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = value @@ -5779,10 +7047,10 @@ class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param status: The private link service connection status. - :type status: str - :param description: The private link service connection description. - :type description: str + :ivar status: The private link service connection status. + :vartype status: str + :ivar description: The private link service connection description. + :vartype description: str :ivar actions_required: Any action that is required beyond basic workflow (approve/ reject/ disconnect). :vartype actions_required: str @@ -5805,6 +7073,12 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword status: The private link service connection status. + :paramtype status: str + :keyword description: The private link service connection description. + :paramtype description: str + """ super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) self.status = status self.description = description @@ -5816,8 +7090,8 @@ class RegionForOnlineOffline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param region: Required. Cosmos DB region, with spaces between words and each word capitalized. - :type region: str + :ivar region: Required. Cosmos DB region, with spaces between words and each word capitalized. + :vartype region: str """ _validation = { @@ -5834,6 +7108,11 @@ def __init__( region: str, **kwargs ): + """ + :keyword region: Required. Cosmos DB region, with spaces between words and each word + capitalized. + :paramtype region: str + """ super(RegionForOnlineOffline, self).__init__(**kwargs) self.region = region @@ -5849,15 +7128,15 @@ class RestorableDatabaseAccountGetResult(msrest.serialization.Model): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param account_name: The name of the global database account. - :type account_name: str - :param creation_time: The creation time of the restorable database account (ISO-8601 format). - :type creation_time: ~datetime.datetime - :param deletion_time: The time at which the restorable database account has been deleted + :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. + :vartype account_name: str + :ivar creation_time: The creation time of the restorable database account (ISO-8601 format). + :vartype creation_time: ~datetime.datetime + :ivar deletion_time: The time at which the restorable database account has been deleted (ISO-8601 format). - :type deletion_time: ~datetime.datetime + :vartype deletion_time: ~datetime.datetime :ivar api_type: The API type of the restorable database account. Possible values include: "MongoDB", "Gremlin", "Cassandra", "Table", "Sql", "GremlinV2". :vartype api_type: str or ~azure.mgmt.cosmosdb.models.ApiType @@ -5895,6 +7174,17 @@ def __init__( deletion_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword account_name: The name of the global database account. + :paramtype account_name: str + :keyword creation_time: The creation time of the restorable database account (ISO-8601 format). + :paramtype creation_time: ~datetime.datetime + :keyword deletion_time: The time at which the restorable database account has been deleted + (ISO-8601 format). + :paramtype deletion_time: ~datetime.datetime + """ super(RestorableDatabaseAccountGetResult, self).__init__(**kwargs) self.id = None self.name = None @@ -5928,6 +7218,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableDatabaseAccountsListResult, self).__init__(**kwargs) self.value = None @@ -5968,6 +7260,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableLocationResource, self).__init__(**kwargs) self.location_name = None self.regional_database_account_instance_id = None @@ -5986,8 +7280,8 @@ class RestorableMongodbCollectionGetResult(msrest.serialization.Model): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param resource: The resource of an Azure Cosmos DB MongoDB collection event. - :type resource: ~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionPropertiesResource + :ivar resource: The resource of an Azure Cosmos DB MongoDB collection event. + :vartype resource: ~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionPropertiesResource """ _validation = { @@ -6009,6 +7303,10 @@ def __init__( resource: Optional["RestorableMongodbCollectionPropertiesResource"] = None, **kwargs ): + """ + :keyword resource: The resource of an Azure Cosmos DB MongoDB collection event. + :paramtype resource: ~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionPropertiesResource + """ super(RestorableMongodbCollectionGetResult, self).__init__(**kwargs) self.id = None self.name = None @@ -6054,6 +7352,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableMongodbCollectionPropertiesResource, self).__init__(**kwargs) self.rid = None self.operation_type = None @@ -6083,6 +7383,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableMongodbCollectionsListResult, self).__init__(**kwargs) self.value = None @@ -6098,8 +7400,8 @@ class RestorableMongodbDatabaseGetResult(msrest.serialization.Model): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param resource: The resource of an Azure Cosmos DB MongoDB database event. - :type resource: ~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasePropertiesResource + :ivar resource: The resource of an Azure Cosmos DB MongoDB database event. + :vartype resource: ~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasePropertiesResource """ _validation = { @@ -6121,6 +7423,10 @@ def __init__( resource: Optional["RestorableMongodbDatabasePropertiesResource"] = None, **kwargs ): + """ + :keyword resource: The resource of an Azure Cosmos DB MongoDB database event. + :paramtype resource: ~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasePropertiesResource + """ super(RestorableMongodbDatabaseGetResult, self).__init__(**kwargs) self.id = None self.name = None @@ -6166,6 +7472,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableMongodbDatabasePropertiesResource, self).__init__(**kwargs) self.rid = None self.operation_type = None @@ -6195,6 +7503,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableMongodbDatabasesListResult, self).__init__(**kwargs) self.value = None @@ -6220,6 +7530,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableMongodbResourcesListResult, self).__init__(**kwargs) self.value = None @@ -6235,8 +7547,8 @@ class RestorableSqlContainerGetResult(msrest.serialization.Model): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param resource: The resource of an Azure Cosmos DB SQL container event. - :type resource: ~azure.mgmt.cosmosdb.models.RestorableSqlContainerPropertiesResource + :ivar resource: The resource of an Azure Cosmos DB SQL container event. + :vartype resource: ~azure.mgmt.cosmosdb.models.RestorableSqlContainerPropertiesResource """ _validation = { @@ -6258,6 +7570,10 @@ def __init__( resource: Optional["RestorableSqlContainerPropertiesResource"] = None, **kwargs ): + """ + :keyword resource: The resource of an Azure Cosmos DB SQL container event. + :paramtype resource: ~azure.mgmt.cosmosdb.models.RestorableSqlContainerPropertiesResource + """ super(RestorableSqlContainerGetResult, self).__init__(**kwargs) self.id = None self.name = None @@ -6281,8 +7597,9 @@ class RestorableSqlContainerPropertiesResource(msrest.serialization.Model): :vartype owner_id: str :ivar owner_resource_id: The resource ID of this SQL container. :vartype owner_resource_id: str - :param container: Cosmos DB SQL container resource object. - :type container: ~azure.mgmt.cosmosdb.models.RestorableSqlContainerPropertiesResourceContainer + :ivar container: Cosmos DB SQL container resource object. + :vartype container: + ~azure.mgmt.cosmosdb.models.RestorableSqlContainerPropertiesResourceContainer """ _validation = { @@ -6308,6 +7625,11 @@ def __init__( container: Optional["RestorableSqlContainerPropertiesResourceContainer"] = None, **kwargs ): + """ + :keyword container: Cosmos DB SQL container resource object. + :paramtype container: + ~azure.mgmt.cosmosdb.models.RestorableSqlContainerPropertiesResourceContainer + """ super(RestorableSqlContainerPropertiesResource, self).__init__(**kwargs) self.rid = None self.operation_type = None @@ -6322,23 +7644,23 @@ class SqlContainerResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL container. - :type id: str - :param indexing_policy: The configuration of the indexing policy. By default, the indexing is + :ivar id: Required. Name of the Cosmos DB SQL container. + :vartype id: str + :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container. - :type indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy - :param partition_key: The configuration of the partition key to be used for partitioning data + :vartype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :ivar partition_key: The configuration of the partition key to be used for partitioning data into multiple partitions. - :type partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey - :param default_ttl: Default time to live. - :type default_ttl: int - :param unique_key_policy: The unique key policy configuration for specifying uniqueness + :vartype partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey + :ivar default_ttl: Default time to live. + :vartype default_ttl: int + :ivar unique_key_policy: The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - :type unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy - :param conflict_resolution_policy: The conflict resolution policy for the container. - :type conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy - :param analytical_storage_ttl: Analytical TTL. - :type analytical_storage_ttl: long + :vartype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :ivar conflict_resolution_policy: The conflict resolution policy for the container. + :vartype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + :ivar analytical_storage_ttl: Analytical TTL. + :vartype analytical_storage_ttl: long """ _validation = { @@ -6367,6 +7689,25 @@ def __init__( analytical_storage_ttl: Optional[int] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL container. + :paramtype id: str + :keyword indexing_policy: The configuration of the indexing policy. By default, the indexing is + automatic for all document paths within the container. + :paramtype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :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 + :keyword unique_key_policy: The unique key policy configuration for specifying uniqueness + constraints on documents in the collection in the Azure Cosmos DB service. + :paramtype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :keyword conflict_resolution_policy: The conflict resolution policy for the container. + :paramtype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + :keyword analytical_storage_ttl: Analytical TTL. + :paramtype analytical_storage_ttl: long + """ super(SqlContainerResource, self).__init__(**kwargs) self.id = id self.indexing_policy = indexing_policy @@ -6384,23 +7725,23 @@ class RestorableSqlContainerPropertiesResourceContainer(ExtendedResourceProperti All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL container. - :type id: str - :param indexing_policy: The configuration of the indexing policy. By default, the indexing is + :ivar id: Required. Name of the Cosmos DB SQL container. + :vartype id: str + :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container. - :type indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy - :param partition_key: The configuration of the partition key to be used for partitioning data + :vartype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :ivar partition_key: The configuration of the partition key to be used for partitioning data into multiple partitions. - :type partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey - :param default_ttl: Default time to live. - :type default_ttl: int - :param unique_key_policy: The unique key policy configuration for specifying uniqueness + :vartype partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey + :ivar default_ttl: Default time to live. + :vartype default_ttl: int + :ivar unique_key_policy: The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - :type unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy - :param conflict_resolution_policy: The conflict resolution policy for the container. - :type conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy - :param analytical_storage_ttl: Analytical TTL. - :type analytical_storage_ttl: long + :vartype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :ivar conflict_resolution_policy: The conflict resolution policy for the container. + :vartype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + :ivar analytical_storage_ttl: Analytical TTL. + :vartype analytical_storage_ttl: long :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. @@ -6447,6 +7788,25 @@ def __init__( analytical_storage_ttl: Optional[int] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL container. + :paramtype id: str + :keyword indexing_policy: The configuration of the indexing policy. By default, the indexing is + automatic for all document paths within the container. + :paramtype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :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 + :keyword unique_key_policy: The unique key policy configuration for specifying uniqueness + constraints on documents in the collection in the Azure Cosmos DB service. + :paramtype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :keyword conflict_resolution_policy: The conflict resolution policy for the container. + :paramtype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + :keyword analytical_storage_ttl: Analytical TTL. + :paramtype analytical_storage_ttl: long + """ super(RestorableSqlContainerPropertiesResourceContainer, self).__init__(id=id, indexing_policy=indexing_policy, partition_key=partition_key, default_ttl=default_ttl, unique_key_policy=unique_key_policy, conflict_resolution_policy=conflict_resolution_policy, analytical_storage_ttl=analytical_storage_ttl, **kwargs) self.id = id self.indexing_policy = indexing_policy @@ -6483,6 +7843,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableSqlContainersListResult, self).__init__(**kwargs) self.value = None @@ -6498,8 +7860,8 @@ class RestorableSqlDatabaseGetResult(msrest.serialization.Model): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param resource: The resource of an Azure Cosmos DB SQL database event. - :type resource: ~azure.mgmt.cosmosdb.models.RestorableSqlDatabasePropertiesResource + :ivar resource: The resource of an Azure Cosmos DB SQL database event. + :vartype resource: ~azure.mgmt.cosmosdb.models.RestorableSqlDatabasePropertiesResource """ _validation = { @@ -6521,6 +7883,10 @@ def __init__( resource: Optional["RestorableSqlDatabasePropertiesResource"] = None, **kwargs ): + """ + :keyword resource: The resource of an Azure Cosmos DB SQL database event. + :paramtype resource: ~azure.mgmt.cosmosdb.models.RestorableSqlDatabasePropertiesResource + """ super(RestorableSqlDatabaseGetResult, self).__init__(**kwargs) self.id = None self.name = None @@ -6544,8 +7910,8 @@ class RestorableSqlDatabasePropertiesResource(msrest.serialization.Model): :vartype owner_id: str :ivar owner_resource_id: The resource ID of the SQL database. :vartype owner_resource_id: str - :param database: Cosmos DB SQL database resource object. - :type database: ~azure.mgmt.cosmosdb.models.RestorableSqlDatabasePropertiesResourceDatabase + :ivar database: Cosmos DB SQL database resource object. + :vartype database: ~azure.mgmt.cosmosdb.models.RestorableSqlDatabasePropertiesResourceDatabase """ _validation = { @@ -6571,6 +7937,11 @@ def __init__( database: Optional["RestorableSqlDatabasePropertiesResourceDatabase"] = None, **kwargs ): + """ + :keyword database: Cosmos DB SQL database resource object. + :paramtype database: + ~azure.mgmt.cosmosdb.models.RestorableSqlDatabasePropertiesResourceDatabase + """ super(RestorableSqlDatabasePropertiesResource, self).__init__(**kwargs) self.rid = None self.operation_type = None @@ -6585,8 +7956,8 @@ class SqlDatabaseResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL database. - :type id: str + :ivar id: Required. Name of the Cosmos DB SQL database. + :vartype id: str """ _validation = { @@ -6603,6 +7974,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL database. + :paramtype id: str + """ super(SqlDatabaseResource, self).__init__(**kwargs) self.id = id @@ -6621,8 +7996,8 @@ class RestorableSqlDatabasePropertiesResourceDatabase(SqlDatabaseResource, Exten :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :param id: Required. Name of the Cosmos DB SQL database. - :type id: str + :ivar id: Required. Name of the Cosmos DB SQL database. + :vartype id: str :ivar colls: A system generated property that specified the addressable path of the collections resource. :vartype colls: str @@ -6660,6 +8035,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL database. + :paramtype id: str + """ super(RestorableSqlDatabasePropertiesResourceDatabase, self).__init__(id=id, **kwargs) self.rid = None self.ts = None @@ -6694,6 +8073,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableSqlDatabasesListResult, self).__init__(**kwargs) self.value = None @@ -6719,6 +8100,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestorableSqlResourcesListResult, self).__init__(**kwargs) self.value = None @@ -6726,17 +8109,16 @@ def __init__( class RestoreParameters(msrest.serialization.Model): """Parameters to indicate the information about the restore. - :param restore_mode: Describes the mode of the restore. Possible values include: "PointInTime". - :type restore_mode: str or ~azure.mgmt.cosmosdb.models.RestoreMode - :param restore_source: The id of the restorable database account from which the restore has to + :ivar restore_mode: Describes the mode of the restore. Possible values include: "PointInTime". + :vartype restore_mode: str or ~azure.mgmt.cosmosdb.models.RestoreMode + :ivar restore_source: The id of the restorable database account from which the restore has to be initiated. For example: /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{restorableDatabaseAccountName}. - :type restore_source: str - :param restore_timestamp_in_utc: Time to which the account has to be restored (ISO-8601 - format). - :type restore_timestamp_in_utc: ~datetime.datetime - :param databases_to_restore: List of specific databases available for restore. - :type databases_to_restore: list[~azure.mgmt.cosmosdb.models.DatabaseRestoreResource] + :vartype restore_source: str + :ivar restore_timestamp_in_utc: Time to which the account has to be restored (ISO-8601 format). + :vartype restore_timestamp_in_utc: ~datetime.datetime + :ivar databases_to_restore: List of specific databases available for restore. + :vartype databases_to_restore: list[~azure.mgmt.cosmosdb.models.DatabaseRestoreResource] """ _attribute_map = { @@ -6755,6 +8137,20 @@ def __init__( databases_to_restore: Optional[List["DatabaseRestoreResource"]] = None, **kwargs ): + """ + :keyword restore_mode: Describes the mode of the restore. Possible values include: + "PointInTime". + :paramtype restore_mode: str or ~azure.mgmt.cosmosdb.models.RestoreMode + :keyword restore_source: The id of the restorable database account from which the restore has + to be initiated. For example: + /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{restorableDatabaseAccountName}. + :paramtype restore_source: str + :keyword restore_timestamp_in_utc: Time to which the account has to be restored (ISO-8601 + format). + :paramtype restore_timestamp_in_utc: ~datetime.datetime + :keyword databases_to_restore: List of specific databases available for restore. + :paramtype databases_to_restore: list[~azure.mgmt.cosmosdb.models.DatabaseRestoreResource] + """ super(RestoreParameters, self).__init__(**kwargs) self.restore_mode = restore_mode self.restore_source = restore_source @@ -6765,8 +8161,8 @@ def __init__( class SeedNode(msrest.serialization.Model): """SeedNode. - :param ip_address: IP address of this seed node. - :type ip_address: str + :ivar ip_address: IP address of this seed node. + :vartype ip_address: str """ _attribute_map = { @@ -6779,6 +8175,10 @@ def __init__( ip_address: Optional[str] = None, **kwargs ): + """ + :keyword ip_address: IP address of this seed node. + :paramtype ip_address: str + """ super(SeedNode, self).__init__(**kwargs) self.ip_address = ip_address @@ -6786,11 +8186,11 @@ def __init__( class SpatialSpec(msrest.serialization.Model): """SpatialSpec. - :param path: The path for which the indexing behavior applies to. Index paths typically start + :ivar path: The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*). - :type path: str - :param types: List of path's spatial type. - :type types: list[str or ~azure.mgmt.cosmosdb.models.SpatialType] + :vartype path: str + :ivar types: List of path's spatial type. + :vartype types: list[str or ~azure.mgmt.cosmosdb.models.SpatialType] """ _attribute_map = { @@ -6805,6 +8205,13 @@ def __init__( types: Optional[List[Union[str, "SpatialType"]]] = None, **kwargs ): + """ + :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 types: List of path's spatial type. + :paramtype types: list[str or ~azure.mgmt.cosmosdb.models.SpatialType] + """ super(SpatialSpec, self).__init__(**kwargs) self.path = path self.types = types @@ -6823,20 +8230,20 @@ class SqlContainerCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a container. - :type resource: ~azure.mgmt.cosmosdb.models.SqlContainerResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a container. + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlContainerResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -6865,6 +8272,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a container. + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlContainerResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(SqlContainerCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -6873,11 +8296,11 @@ def __init__( class SqlContainerGetPropertiesOptions(OptionsResource): """SqlContainerGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -6892,6 +8315,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(SqlContainerGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -6902,23 +8332,23 @@ class SqlContainerGetPropertiesResource(ExtendedResourceProperties, SqlContainer All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL container. - :type id: str - :param indexing_policy: The configuration of the indexing policy. By default, the indexing is + :ivar id: Required. Name of the Cosmos DB SQL container. + :vartype id: str + :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container. - :type indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy - :param partition_key: The configuration of the partition key to be used for partitioning data + :vartype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :ivar partition_key: The configuration of the partition key to be used for partitioning data into multiple partitions. - :type partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey - :param default_ttl: Default time to live. - :type default_ttl: int - :param unique_key_policy: The unique key policy configuration for specifying uniqueness + :vartype partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey + :ivar default_ttl: Default time to live. + :vartype default_ttl: int + :ivar unique_key_policy: The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - :type unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy - :param conflict_resolution_policy: The conflict resolution policy for the container. - :type conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy - :param analytical_storage_ttl: Analytical TTL. - :type analytical_storage_ttl: long + :vartype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :ivar conflict_resolution_policy: The conflict resolution policy for the container. + :vartype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + :ivar analytical_storage_ttl: Analytical TTL. + :vartype analytical_storage_ttl: long :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. @@ -6960,6 +8390,25 @@ def __init__( analytical_storage_ttl: Optional[int] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL container. + :paramtype id: str + :keyword indexing_policy: The configuration of the indexing policy. By default, the indexing is + automatic for all document paths within the container. + :paramtype indexing_policy: ~azure.mgmt.cosmosdb.models.IndexingPolicy + :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 + :keyword unique_key_policy: The unique key policy configuration for specifying uniqueness + constraints on documents in the collection in the Azure Cosmos DB service. + :paramtype unique_key_policy: ~azure.mgmt.cosmosdb.models.UniqueKeyPolicy + :keyword conflict_resolution_policy: The conflict resolution policy for the container. + :paramtype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy + :keyword analytical_storage_ttl: Analytical TTL. + :paramtype analytical_storage_ttl: long + """ super(SqlContainerGetPropertiesResource, self).__init__(id=id, indexing_policy=indexing_policy, partition_key=partition_key, default_ttl=default_ttl, unique_key_policy=unique_key_policy, conflict_resolution_policy=conflict_resolution_policy, analytical_storage_ttl=analytical_storage_ttl, **kwargs) self.id = id self.indexing_policy = indexing_policy @@ -6984,19 +8433,19 @@ class SqlContainerGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.SqlContainerGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.SqlContainerGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlContainerGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.SqlContainerGetPropertiesOptions """ _validation = { @@ -7024,6 +8473,21 @@ def __init__( options: Optional["SqlContainerGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlContainerGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.SqlContainerGetPropertiesOptions + """ super(SqlContainerGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -7050,6 +8514,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlContainerListResult, self).__init__(**kwargs) self.value = None @@ -7067,20 +8533,20 @@ class SqlDatabaseCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a SQL database. - :type resource: ~azure.mgmt.cosmosdb.models.SqlDatabaseResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a SQL database. + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlDatabaseResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -7109,6 +8575,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a SQL database. + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlDatabaseResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(SqlDatabaseCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -7117,11 +8599,11 @@ def __init__( class SqlDatabaseGetPropertiesOptions(OptionsResource): """SqlDatabaseGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -7136,6 +8618,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(SqlDatabaseGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -7153,14 +8642,14 @@ class SqlDatabaseGetPropertiesResource(SqlDatabaseResource, ExtendedResourceProp :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :param id: Required. Name of the Cosmos DB SQL database. - :type id: str - :param colls: A system generated property that specified the addressable path of the - collections resource. - :type colls: str - :param users: A system generated property that specifies the addressable path of the users + :ivar id: Required. Name of the Cosmos DB SQL database. + :vartype id: str + :ivar colls: A system generated property that specified the addressable path of the collections resource. - :type users: str + :vartype colls: str + :ivar users: A system generated property that specifies the addressable path of the users + resource. + :vartype users: str """ _validation = { @@ -7187,6 +8676,16 @@ def __init__( users: Optional[str] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL database. + :paramtype id: str + :keyword colls: A system generated property that specified the addressable path of the + collections resource. + :paramtype colls: str + :keyword users: A system generated property that specifies the addressable path of the users + resource. + :paramtype users: str + """ super(SqlDatabaseGetPropertiesResource, self).__init__(id=id, **kwargs) self.rid = None self.ts = None @@ -7209,19 +8708,19 @@ class SqlDatabaseGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetPropertiesOptions """ _validation = { @@ -7249,6 +8748,21 @@ def __init__( options: Optional["SqlDatabaseGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetPropertiesOptions + """ super(SqlDatabaseGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -7275,6 +8789,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlDatabaseListResult, self).__init__(**kwargs) self.value = None @@ -7282,15 +8798,15 @@ def __init__( class SqlRoleAssignmentCreateUpdateParameters(msrest.serialization.Model): """Parameters to create and update an Azure Cosmos DB SQL Role Assignment. - :param role_definition_id: The unique identifier for the associated Role Definition. - :type role_definition_id: str - :param scope: The data plane resource path for which access is being granted through this Role + :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 Assignment. - :type scope: str - :param principal_id: The unique identifier for the associated AAD principal in the AAD graph to + :vartype scope: str + :ivar principal_id: The unique identifier for the associated AAD principal in the AAD graph to which access is being granted through this Role Assignment. Tenant ID for the principal is inferred using the tenant associated with the subscription. - :type principal_id: str + :vartype principal_id: str """ _attribute_map = { @@ -7307,6 +8823,17 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword role_definition_id: The unique identifier for the associated Role Definition. + :paramtype role_definition_id: str + :keyword scope: The data plane resource path for which access is being granted through this + Role Assignment. + :paramtype scope: str + :keyword principal_id: The unique identifier for the associated AAD principal in the AAD graph + to which access is being granted through this Role Assignment. Tenant ID for the principal is + inferred using the tenant associated with the subscription. + :paramtype principal_id: str + """ super(SqlRoleAssignmentCreateUpdateParameters, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.scope = scope @@ -7324,15 +8851,15 @@ class SqlRoleAssignmentGetResults(ARMProxyResource): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param role_definition_id: The unique identifier for the associated Role Definition. - :type role_definition_id: str - :param scope: The data plane resource path for which access is being granted through this Role + :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 Assignment. - :type scope: str - :param principal_id: The unique identifier for the associated AAD principal in the AAD graph to + :vartype scope: str + :ivar principal_id: The unique identifier for the associated AAD principal in the AAD graph to which access is being granted through this Role Assignment. Tenant ID for the principal is inferred using the tenant associated with the subscription. - :type principal_id: str + :vartype principal_id: str """ _validation = { @@ -7358,6 +8885,17 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword role_definition_id: The unique identifier for the associated Role Definition. + :paramtype role_definition_id: str + :keyword scope: The data plane resource path for which access is being granted through this + Role Assignment. + :paramtype scope: str + :keyword principal_id: The unique identifier for the associated AAD principal in the AAD graph + to which access is being granted through this Role Assignment. Tenant ID for the principal is + inferred using the tenant associated with the subscription. + :paramtype principal_id: str + """ super(SqlRoleAssignmentGetResults, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.scope = scope @@ -7385,6 +8923,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlRoleAssignmentListResult, self).__init__(**kwargs) self.value = None @@ -7392,20 +8932,20 @@ def __init__( class SqlRoleDefinitionCreateUpdateParameters(msrest.serialization.Model): """Parameters to create and update an Azure Cosmos DB SQL Role Definition. - :param role_name: A user-friendly name for the Role Definition. Must be unique for the database + :ivar role_name: A user-friendly name for the Role Definition. Must be unique for the database account. - :type role_name: str - :param type: Indicates whether the Role Definition was built-in or user created. Possible - values include: "BuiltInRole", "CustomRole". - :type type: str or ~azure.mgmt.cosmosdb.models.RoleDefinitionType - :param assignable_scopes: A set of fully qualified Scopes at or below which Role Assignments - may be created using this Role Definition. This will allow application of this Role Definition - on the entire database account or any underlying Database / Collection. Must have at least one + :vartype role_name: str + :ivar type: Indicates whether the Role Definition was built-in or user created. Possible values + include: "BuiltInRole", "CustomRole". + :vartype type: str or ~azure.mgmt.cosmosdb.models.RoleDefinitionType + :ivar assignable_scopes: A set of fully qualified Scopes at or below which Role Assignments may + be created using this Role Definition. This will allow application of this Role Definition on + the entire database account or any underlying Database / Collection. Must have at least one element. Scopes higher than Database account are not enforceable as assignable Scopes. Note that resources referenced in assignable Scopes need not exist. - :type assignable_scopes: list[str] - :param permissions: The set of operations allowed through this Role Definition. - :type permissions: list[~azure.mgmt.cosmosdb.models.Permission] + :vartype assignable_scopes: list[str] + :ivar permissions: The set of operations allowed through this Role Definition. + :vartype permissions: list[~azure.mgmt.cosmosdb.models.Permission] """ _attribute_map = { @@ -7424,6 +8964,22 @@ def __init__( permissions: Optional[List["Permission"]] = None, **kwargs ): + """ + :keyword role_name: A user-friendly name for the Role Definition. Must be unique for the + database account. + :paramtype role_name: str + :keyword type: Indicates whether the Role Definition was built-in or user created. Possible + values include: "BuiltInRole", "CustomRole". + :paramtype type: str or ~azure.mgmt.cosmosdb.models.RoleDefinitionType + :keyword assignable_scopes: A set of fully qualified Scopes at or below which Role Assignments + may be created using this Role Definition. This will allow application of this Role Definition + on the entire database account or any underlying Database / Collection. Must have at least one + element. Scopes higher than Database account are not enforceable as assignable Scopes. Note + 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.Permission] + """ super(SqlRoleDefinitionCreateUpdateParameters, self).__init__(**kwargs) self.role_name = role_name self.type = type @@ -7442,20 +8998,20 @@ class SqlRoleDefinitionGetResults(ARMProxyResource): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param role_name: A user-friendly name for the Role Definition. Must be unique for the database + :ivar role_name: A user-friendly name for the Role Definition. Must be unique for the database account. - :type role_name: str - :param type_properties_type: Indicates whether the Role Definition was built-in or user - created. Possible values include: "BuiltInRole", "CustomRole". - :type type_properties_type: str or ~azure.mgmt.cosmosdb.models.RoleDefinitionType - :param assignable_scopes: A set of fully qualified Scopes at or below which Role Assignments - may be created using this Role Definition. This will allow application of this Role Definition - on the entire database account or any underlying Database / Collection. Must have at least one + :vartype role_name: str + :ivar type_properties_type: Indicates whether the Role Definition was built-in or user created. + Possible values include: "BuiltInRole", "CustomRole". + :vartype type_properties_type: str or ~azure.mgmt.cosmosdb.models.RoleDefinitionType + :ivar assignable_scopes: A set of fully qualified Scopes at or below which Role Assignments may + be created using this Role Definition. This will allow application of this Role Definition on + the entire database account or any underlying Database / Collection. Must have at least one element. Scopes higher than Database account are not enforceable as assignable Scopes. Note that resources referenced in assignable Scopes need not exist. - :type assignable_scopes: list[str] - :param permissions: The set of operations allowed through this Role Definition. - :type permissions: list[~azure.mgmt.cosmosdb.models.Permission] + :vartype assignable_scopes: list[str] + :ivar permissions: The set of operations allowed through this Role Definition. + :vartype permissions: list[~azure.mgmt.cosmosdb.models.Permission] """ _validation = { @@ -7483,6 +9039,22 @@ def __init__( permissions: Optional[List["Permission"]] = None, **kwargs ): + """ + :keyword role_name: A user-friendly name for the Role Definition. Must be unique for the + database account. + :paramtype role_name: str + :keyword type_properties_type: Indicates whether the Role Definition was built-in or user + created. Possible values include: "BuiltInRole", "CustomRole". + :paramtype type_properties_type: str or ~azure.mgmt.cosmosdb.models.RoleDefinitionType + :keyword assignable_scopes: A set of fully qualified Scopes at or below which Role Assignments + may be created using this Role Definition. This will allow application of this Role Definition + on the entire database account or any underlying Database / Collection. Must have at least one + element. Scopes higher than Database account are not enforceable as assignable Scopes. Note + 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.Permission] + """ super(SqlRoleDefinitionGetResults, self).__init__(**kwargs) self.role_name = role_name self.type_properties_type = type_properties_type @@ -7511,6 +9083,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlRoleDefinitionListResult, self).__init__(**kwargs) self.value = None @@ -7528,20 +9102,20 @@ class SqlStoredProcedureCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a storedProcedure. - :type resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a storedProcedure. + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -7570,6 +9144,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a storedProcedure. + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(SqlStoredProcedureCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -7580,10 +9170,10 @@ class SqlStoredProcedureResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL storedProcedure. - :type id: str - :param body: Body of the Stored Procedure. - :type body: str + :ivar id: Required. Name of the Cosmos DB SQL storedProcedure. + :vartype id: str + :ivar body: Body of the Stored Procedure. + :vartype body: str """ _validation = { @@ -7602,6 +9192,12 @@ def __init__( body: Optional[str] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL storedProcedure. + :paramtype id: str + :keyword body: Body of the Stored Procedure. + :paramtype body: str + """ super(SqlStoredProcedureResource, self).__init__(**kwargs) self.id = id self.body = body @@ -7614,10 +9210,10 @@ class SqlStoredProcedureGetPropertiesResource(ExtendedResourceProperties, SqlSto All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL storedProcedure. - :type id: str - :param body: Body of the Stored Procedure. - :type body: str + :ivar id: Required. Name of the Cosmos DB SQL storedProcedure. + :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. @@ -7649,6 +9245,12 @@ def __init__( body: Optional[str] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL storedProcedure. + :paramtype id: str + :keyword body: Body of the Stored Procedure. + :paramtype body: str + """ super(SqlStoredProcedureGetPropertiesResource, self).__init__(id=id, body=body, **kwargs) self.id = id self.body = body @@ -7668,17 +9270,17 @@ class SqlStoredProcedureGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetPropertiesResource + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetPropertiesResource """ _validation = { @@ -7704,6 +9306,19 @@ def __init__( resource: Optional["SqlStoredProcedureGetPropertiesResource"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetPropertiesResource + """ super(SqlStoredProcedureGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource @@ -7729,6 +9344,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlStoredProcedureListResult, self).__init__(**kwargs) self.value = None @@ -7746,20 +9363,20 @@ class SqlTriggerCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a trigger. - :type resource: ~azure.mgmt.cosmosdb.models.SqlTriggerResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a trigger. + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlTriggerResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -7788,6 +9405,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a trigger. + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlTriggerResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(SqlTriggerCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -7798,15 +9431,15 @@ class SqlTriggerResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL trigger. - :type id: str - :param body: Body of the Trigger. - :type body: str - :param trigger_type: Type of the Trigger. Possible values include: "Pre", "Post". - :type trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType - :param trigger_operation: The operation the trigger is associated with. Possible values - include: "All", "Create", "Update", "Delete", "Replace". - :type trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation + :ivar id: Required. Name of the Cosmos DB SQL trigger. + :vartype id: str + :ivar body: Body of the Trigger. + :vartype body: str + :ivar trigger_type: Type of the Trigger. Possible values include: "Pre", "Post". + :vartype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType + :ivar trigger_operation: The operation the trigger is associated with. Possible values include: + "All", "Create", "Update", "Delete", "Replace". + :vartype trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation """ _validation = { @@ -7829,6 +9462,17 @@ def __init__( trigger_operation: Optional[Union[str, "TriggerOperation"]] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL trigger. + :paramtype id: str + :keyword body: Body of the Trigger. + :paramtype body: str + :keyword trigger_type: Type of the Trigger. Possible values include: "Pre", "Post". + :paramtype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType + :keyword trigger_operation: The operation the trigger is associated with. Possible values + include: "All", "Create", "Update", "Delete", "Replace". + :paramtype trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation + """ super(SqlTriggerResource, self).__init__(**kwargs) self.id = id self.body = body @@ -7843,15 +9487,15 @@ class SqlTriggerGetPropertiesResource(ExtendedResourceProperties, SqlTriggerReso All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL trigger. - :type id: str - :param body: Body of the Trigger. - :type body: str - :param trigger_type: Type of the Trigger. Possible values include: "Pre", "Post". - :type trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType - :param trigger_operation: The operation the trigger is associated with. Possible values - include: "All", "Create", "Update", "Delete", "Replace". - :type trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation + :ivar id: Required. Name of the Cosmos DB SQL trigger. + :vartype id: str + :ivar body: Body of the Trigger. + :vartype body: str + :ivar trigger_type: Type of the Trigger. Possible values include: "Pre", "Post". + :vartype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType + :ivar trigger_operation: The operation the trigger is associated with. Possible values include: + "All", "Create", "Update", "Delete", "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. @@ -7887,6 +9531,17 @@ def __init__( trigger_operation: Optional[Union[str, "TriggerOperation"]] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL trigger. + :paramtype id: str + :keyword body: Body of the Trigger. + :paramtype body: str + :keyword trigger_type: Type of the Trigger. Possible values include: "Pre", "Post". + :paramtype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType + :keyword trigger_operation: The operation the trigger is associated with. Possible values + include: "All", "Create", "Update", "Delete", "Replace". + :paramtype trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation + """ super(SqlTriggerGetPropertiesResource, self).__init__(id=id, body=body, trigger_type=trigger_type, trigger_operation=trigger_operation, **kwargs) self.id = id self.body = body @@ -7908,17 +9563,17 @@ class SqlTriggerGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.SqlTriggerGetPropertiesResource + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlTriggerGetPropertiesResource """ _validation = { @@ -7944,6 +9599,19 @@ def __init__( resource: Optional["SqlTriggerGetPropertiesResource"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlTriggerGetPropertiesResource + """ super(SqlTriggerGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource @@ -7969,6 +9637,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlTriggerListResult, self).__init__(**kwargs) self.value = None @@ -7986,20 +9656,20 @@ class SqlUserDefinedFunctionCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a userDefinedFunction. - :type resource: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a userDefinedFunction. + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -8028,6 +9698,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a userDefinedFunction. + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(SqlUserDefinedFunctionCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -8038,10 +9724,10 @@ class SqlUserDefinedFunctionResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL userDefinedFunction. - :type id: str - :param body: Body of the User Defined Function. - :type body: str + :ivar id: Required. Name of the Cosmos DB SQL userDefinedFunction. + :vartype id: str + :ivar body: Body of the User Defined Function. + :vartype body: str """ _validation = { @@ -8060,6 +9746,12 @@ def __init__( body: Optional[str] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL userDefinedFunction. + :paramtype id: str + :keyword body: Body of the User Defined Function. + :paramtype body: str + """ super(SqlUserDefinedFunctionResource, self).__init__(**kwargs) self.id = id self.body = body @@ -8072,10 +9764,10 @@ class SqlUserDefinedFunctionGetPropertiesResource(ExtendedResourceProperties, Sq All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB SQL userDefinedFunction. - :type id: str - :param body: Body of the User Defined Function. - :type body: str + :ivar id: Required. Name of the Cosmos DB SQL userDefinedFunction. + :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. @@ -8107,6 +9799,12 @@ def __init__( body: Optional[str] = None, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB SQL userDefinedFunction. + :paramtype id: str + :keyword body: Body of the User Defined Function. + :paramtype body: str + """ super(SqlUserDefinedFunctionGetPropertiesResource, self).__init__(id=id, body=body, **kwargs) self.id = id self.body = body @@ -8126,17 +9824,17 @@ class SqlUserDefinedFunctionGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetPropertiesResource + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetPropertiesResource """ _validation = { @@ -8162,6 +9860,19 @@ def __init__( resource: Optional["SqlUserDefinedFunctionGetPropertiesResource"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetPropertiesResource + """ super(SqlUserDefinedFunctionGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource @@ -8187,6 +9898,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlUserDefinedFunctionListResult, self).__init__(**kwargs) self.value = None @@ -8194,20 +9907,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.cosmosdb.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.cosmosdb.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.cosmosdb.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~azure.mgmt.cosmosdb.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -8230,6 +9943,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.cosmosdb.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.cosmosdb.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -8252,20 +9981,20 @@ class TableCreateUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a Table. - :type resource: ~azure.mgmt.cosmosdb.models.TableResource - :param options: A key-value pair of options to be applied for the request. This corresponds to + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a Table. + :vartype resource: ~azure.mgmt.cosmosdb.models.TableResource + :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - :type options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + :vartype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions """ _validation = { @@ -8294,6 +10023,22 @@ def __init__( options: Optional["CreateUpdateOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a Table. + :paramtype resource: ~azure.mgmt.cosmosdb.models.TableResource + :keyword options: A key-value pair of options to be applied for the request. This corresponds + to the headers sent with the request. + :paramtype options: ~azure.mgmt.cosmosdb.models.CreateUpdateOptions + """ super(TableCreateUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -8302,11 +10047,11 @@ def __init__( class TableGetPropertiesOptions(OptionsResource): """TableGetPropertiesOptions. - :param throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - :type throughput: int - :param autoscale_settings: Specifies the Autoscale settings. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + :vartype throughput: int + :ivar autoscale_settings: Specifies the Autoscale settings. + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ _attribute_map = { @@ -8321,6 +10066,13 @@ def __init__( autoscale_settings: Optional["AutoscaleSettings"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the + ThroughputSetting resource when retrieving offer details. + :paramtype throughput: int + :keyword autoscale_settings: Specifies the Autoscale settings. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings + """ super(TableGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) @@ -8329,8 +10081,8 @@ class TableResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB table. - :type id: str + :ivar id: Required. Name of the Cosmos DB table. + :vartype id: str """ _validation = { @@ -8347,6 +10099,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB table. + :paramtype id: str + """ super(TableResource, self).__init__(**kwargs) self.id = id @@ -8358,8 +10114,8 @@ class TableGetPropertiesResource(ExtendedResourceProperties, TableResource): All required parameters must be populated in order to send to Azure. - :param id: Required. Name of the Cosmos DB table. - :type id: str + :ivar id: Required. Name of the Cosmos DB table. + :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. @@ -8389,6 +10145,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Name of the Cosmos DB table. + :paramtype id: str + """ super(TableGetPropertiesResource, self).__init__(id=id, **kwargs) self.id = id self.rid = None @@ -8407,19 +10167,19 @@ class TableGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.TableGetPropertiesResource - :param options: - :type options: ~azure.mgmt.cosmosdb.models.TableGetPropertiesOptions + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.TableGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.TableGetPropertiesOptions """ _validation = { @@ -8447,6 +10207,21 @@ def __init__( options: Optional["TableGetPropertiesOptions"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.TableGetPropertiesResource + :keyword options: + :paramtype options: ~azure.mgmt.cosmosdb.models.TableGetPropertiesOptions + """ super(TableGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource self.options = options @@ -8473,6 +10248,8 @@ def __init__( self, **kwargs ): + """ + """ super(TableListResult, self).__init__(**kwargs) self.value = None @@ -8480,11 +10257,11 @@ def __init__( class ThroughputPolicyResource(msrest.serialization.Model): """Cosmos DB resource throughput policy. - :param is_enabled: Determines whether the ThroughputPolicy is active or not. - :type is_enabled: bool - :param increment_percent: Represents the percentage by which throughput can increase every time + :ivar is_enabled: Determines whether the ThroughputPolicy is active or not. + :vartype is_enabled: bool + :ivar increment_percent: Represents the percentage by which throughput can increase every time throughput policy kicks in. - :type increment_percent: int + :vartype increment_percent: int """ _attribute_map = { @@ -8499,6 +10276,13 @@ def __init__( increment_percent: Optional[int] = None, **kwargs ): + """ + :keyword is_enabled: Determines whether the ThroughputPolicy is active or not. + :paramtype is_enabled: bool + :keyword increment_percent: Represents the percentage by which throughput can increase every + time throughput policy kicks in. + :paramtype increment_percent: int + """ super(ThroughputPolicyResource, self).__init__(**kwargs) self.is_enabled = is_enabled self.increment_percent = increment_percent @@ -8509,12 +10293,12 @@ class ThroughputSettingsResource(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param throughput: Value of the Cosmos DB resource throughput. Either throughput is required or + :ivar throughput: Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. - :type throughput: int - :param autoscale_settings: Cosmos DB resource for autoscale settings. Either throughput is + :vartype throughput: int + :ivar autoscale_settings: Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettingsResource + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettingsResource :ivar minimum_throughput: The minimum throughput of the resource. :vartype minimum_throughput: str :ivar offer_replace_pending: The throughput replace is pending. @@ -8540,6 +10324,14 @@ def __init__( autoscale_settings: Optional["AutoscaleSettingsResource"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput. Either throughput is required + or autoscaleSettings is required, but not both. + :paramtype throughput: int + :keyword autoscale_settings: Cosmos DB resource for autoscale settings. Either throughput is + required or autoscaleSettings is required, but not both. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettingsResource + """ super(ThroughputSettingsResource, self).__init__(**kwargs) self.throughput = throughput self.autoscale_settings = autoscale_settings @@ -8552,12 +10344,12 @@ class ThroughputSettingsGetPropertiesResource(ExtendedResourceProperties, Throug Variables are only populated by the server, and will be ignored when sending a request. - :param throughput: Value of the Cosmos DB resource throughput. Either throughput is required or + :ivar throughput: Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. - :type throughput: int - :param autoscale_settings: Cosmos DB resource for autoscale settings. Either throughput is + :vartype throughput: int + :ivar autoscale_settings: Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. - :type autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettingsResource + :vartype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettingsResource :ivar minimum_throughput: The minimum throughput of the resource. :vartype minimum_throughput: str :ivar offer_replace_pending: The throughput replace is pending. @@ -8596,6 +10388,14 @@ def __init__( autoscale_settings: Optional["AutoscaleSettingsResource"] = None, **kwargs ): + """ + :keyword throughput: Value of the Cosmos DB resource throughput. Either throughput is required + or autoscaleSettings is required, but not both. + :paramtype throughput: int + :keyword autoscale_settings: Cosmos DB resource for autoscale settings. Either throughput is + required or autoscaleSettings is required, but not both. + :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettingsResource + """ super(ThroughputSettingsGetPropertiesResource, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) self.throughput = throughput self.autoscale_settings = autoscale_settings @@ -8617,17 +10417,17 @@ class ThroughputSettingsGetResults(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: - :type resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetPropertiesResource + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetPropertiesResource """ _validation = { @@ -8653,6 +10453,19 @@ def __init__( resource: Optional["ThroughputSettingsGetPropertiesResource"] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: + :paramtype resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetPropertiesResource + """ super(ThroughputSettingsGetResults, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource @@ -8670,17 +10483,17 @@ class ThroughputSettingsUpdateParameters(ARMResourceProperties): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :param location: The location of the resource group to which the resource belongs. - :type location: str - :param tags: A set of 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". - :type tags: dict[str, str] - :param resource: Required. The standard JSON format of a resource throughput. - :type resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsResource + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar tags: A set of 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 resource: Required. The standard JSON format of a resource throughput. + :vartype resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsResource """ _validation = { @@ -8707,6 +10520,19 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword tags: A set of 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 resource: Required. The standard JSON format of a resource throughput. + :paramtype resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsResource + """ super(ThroughputSettingsUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.resource = resource @@ -8714,8 +10540,8 @@ def __init__( class UniqueKey(msrest.serialization.Model): """The unique key on that enforces uniqueness constraint on documents in the collection in the Azure Cosmos DB service. - :param paths: List of paths must be unique for each document in the Azure Cosmos DB service. - :type paths: list[str] + :ivar paths: List of paths must be unique for each document in the Azure Cosmos DB service. + :vartype paths: list[str] """ _attribute_map = { @@ -8728,6 +10554,10 @@ def __init__( paths: Optional[List[str]] = None, **kwargs ): + """ + :keyword paths: List of paths must be unique for each document in the Azure Cosmos DB service. + :paramtype paths: list[str] + """ super(UniqueKey, self).__init__(**kwargs) self.paths = paths @@ -8735,9 +10565,9 @@ def __init__( class UniqueKeyPolicy(msrest.serialization.Model): """The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - :param unique_keys: List of unique keys on that enforces uniqueness constraint on documents in + :ivar unique_keys: List of unique keys on that enforces uniqueness constraint on documents in the collection in the Azure Cosmos DB service. - :type unique_keys: list[~azure.mgmt.cosmosdb.models.UniqueKey] + :vartype unique_keys: list[~azure.mgmt.cosmosdb.models.UniqueKey] """ _attribute_map = { @@ -8750,6 +10580,11 @@ def __init__( unique_keys: Optional[List["UniqueKey"]] = None, **kwargs ): + """ + :keyword unique_keys: List of unique keys on that enforces uniqueness constraint on documents + in the collection in the Azure Cosmos DB service. + :paramtype unique_keys: list[~azure.mgmt.cosmosdb.models.UniqueKey] + """ super(UniqueKeyPolicy, self).__init__(**kwargs) self.unique_keys = unique_keys @@ -8775,6 +10610,8 @@ def __init__( self, **kwargs ): + """ + """ super(UsagesResult, self).__init__(**kwargs) self.value = None @@ -8782,12 +10619,12 @@ def __init__( class VirtualNetworkRule(msrest.serialization.Model): """Virtual Network ACL Rule object. - :param id: Resource ID of a subnet, for example: + :ivar id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. - :type id: str - :param ignore_missing_v_net_service_endpoint: Create firewall rule before the virtual network + :vartype id: str + :ivar ignore_missing_v_net_service_endpoint: Create firewall rule before the virtual network has vnet service endpoint enabled. - :type ignore_missing_v_net_service_endpoint: bool + :vartype ignore_missing_v_net_service_endpoint: bool """ _attribute_map = { @@ -8802,6 +10639,14 @@ def __init__( ignore_missing_v_net_service_endpoint: Optional[bool] = None, **kwargs ): + """ + :keyword id: Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. + :paramtype id: str + :keyword ignore_missing_v_net_service_endpoint: Create firewall rule before the virtual network + has vnet service endpoint enabled. + :paramtype ignore_missing_v_net_service_endpoint: bool + """ super(VirtualNetworkRule, self).__init__(**kwargs) self.id = id self.ignore_missing_v_net_service_endpoint = ignore_missing_v_net_service_endpoint diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_clusters_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_clusters_operations.py index 00c77a7874ff6..15b49405503d8 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_clusters_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_clusters_operations.py @@ -5,25 +5,399 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_invoke_command_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_deallocate_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_start_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_status_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/status') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CassandraClustersOperations(object): """CassandraClustersOperations operations. @@ -47,11 +421,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListClusters"] + **kwargs: Any + ) -> Iterable["_models.ListClusters"]: """List all managed Cassandra clusters in this subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -64,34 +438,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListClusters', pipeline_response) + deserialized = self._deserialize("ListClusters", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +478,18 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListClusters"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ListClusters"]: """List all managed Cassandra clusters in this resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -134,35 +504,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListClusters', pipeline_response) + deserialized = self._deserialize("ListClusters", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,18 +546,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ClusterResource" + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> "_models.ClusterResource": """Get the properties of a managed Cassandra cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -208,27 +575,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,41 +599,32 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -289,13 +637,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + 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. @@ -304,15 +653,17 @@ def begin_delete( :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -326,21 +677,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -352,47 +696,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore def _create_update_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - body, # type: "_models.ClusterResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ClusterResource" + resource_group_name: str, + cluster_name: str, + body: "_models.ClusterResource", + **kwargs: Any + ) -> "_models.ClusterResource": cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ClusterResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self._create_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ClusterResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -410,16 +744,18 @@ def _create_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore + + @distributed_trace def begin_create_update( self, - resource_group_name, # type: str - cluster_name, # type: str - body, # type: "_models.ClusterResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ClusterResource"] + resource_group_name: str, + cluster_name: str, + body: "_models.ClusterResource", + **kwargs: Any + ) -> LROPoller["_models.ClusterResource"]: """Create or update a managed Cassandra cluster. When updating, you must specify all writable properties. To update only some properties, use PATCH. @@ -431,15 +767,19 @@ def begin_create_update( :type body: ~azure.mgmt.cosmosdb.models.ClusterResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ClusterResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -451,27 +791,21 @@ def begin_create_update( resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ClusterResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -483,47 +817,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - body, # type: "_models.ClusterResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ClusterResource" + resource_group_name: str, + cluster_name: str, + body: "_models.ClusterResource", + **kwargs: Any + ) -> "_models.ClusterResource": cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'ClusterResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ClusterResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -541,16 +865,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - cluster_name, # type: str - body, # type: "_models.ClusterResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ClusterResource"] + resource_group_name: str, + cluster_name: str, + body: "_models.ClusterResource", + **kwargs: Any + ) -> LROPoller["_models.ClusterResource"]: """Updates some of the properties of a managed Cassandra cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -561,15 +887,19 @@ def begin_update( :type body: ~azure.mgmt.cosmosdb.models.ClusterResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ClusterResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -581,27 +911,21 @@ def begin_update( resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ClusterResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -613,47 +937,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}'} # type: ignore def _invoke_command_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - body, # type: "_models.CommandPostBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.CommandOutput" + resource_group_name: str, + cluster_name: str, + body: "_models.CommandPostBody", + **kwargs: Any + ) -> "_models.CommandOutput": cls = kwargs.pop('cls', None) # type: ClsType["_models.CommandOutput"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._invoke_command_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'CommandPostBody') + + request = build_invoke_command_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self._invoke_command_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'CommandPostBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -667,16 +981,18 @@ def _invoke_command_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _invoke_command_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand'} # type: ignore + + @distributed_trace def begin_invoke_command( self, - resource_group_name, # type: str - cluster_name, # type: str - body, # type: "_models.CommandPostBody" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CommandOutput"] + resource_group_name: str, + cluster_name: str, + body: "_models.CommandPostBody", + **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. @@ -687,15 +1003,19 @@ def begin_invoke_command( :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either CommandOutput or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CommandOutput"] lro_delay = kwargs.pop( 'polling_interval', @@ -707,27 +1027,21 @@ def begin_invoke_command( resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CommandOutput', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -739,41 +1053,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_invoke_command.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand'} # type: ignore def _deallocate_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._deallocate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_deallocate_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self._deallocate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -786,13 +1090,14 @@ def _deallocate_initial( _deallocate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate'} # type: ignore + + @distributed_trace def begin_deallocate( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + **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. @@ -803,15 +1108,17 @@ def begin_deallocate( :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -825,21 +1132,14 @@ def begin_deallocate( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -851,41 +1151,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_deallocate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate'} # type: ignore def _start_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -898,13 +1188,14 @@ def _start_initial( _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start'} # type: ignore + + @distributed_trace def begin_start( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Start the Managed Cassandra Cluster and Associated Data Centers. Start will start the host virtual machine of this cluster with reserved data disk. This won't do anything on an already running cluster. Use Deallocate to deallocate the cluster. @@ -915,15 +1206,17 @@ def begin_start( :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -937,21 +1230,14 @@ def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -963,15 +1249,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start'} # type: ignore + @distributed_trace def status( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CassandraClusterPublicStatus" + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> "_models.CassandraClusterPublicStatus": """Gets the CPU, memory, and disk usage statistics for each Cassandra node in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -988,27 +1275,17 @@ def status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_status_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self.status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1022,4 +1299,6 @@ def status( return cls(pipeline_response, deserialized, {}) return deserialized + status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/status'} # type: ignore + diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_data_centers_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_data_centers_operations.py index d0a037bb5c715..6968f8b0eb47f 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_data_centers_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_data_centers_operations.py @@ -5,25 +5,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + "dataCenterName": _SERIALIZER.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + "dataCenterName": _SERIALIZER.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + "dataCenterName": _SERIALIZER.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + "dataCenterName": _SERIALIZER.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CassandraDataCentersOperations(object): """CassandraDataCentersOperations operations. @@ -47,13 +251,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListDataCenters"] + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> Iterable["_models.ListDataCenters"]: """List all data centers in a particular managed Cassandra cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,36 +274,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListDataCenters', pipeline_response) + deserialized = self._deserialize("ListDataCenters", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,19 +318,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - cluster_name, # type: str - data_center_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCenterResource" + resource_group_name: str, + cluster_name: str, + data_center_name: str, + **kwargs: Any + ) -> "_models.DataCenterResource": """Get the properties of a managed Cassandra data center. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -148,28 +350,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + data_center_name=data_center_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,43 +375,34 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - data_center_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cluster_name: str, + data_center_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + data_center_name=data_center_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -232,14 +415,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - cluster_name, # type: str - data_center_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + 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. @@ -250,15 +434,17 @@ def begin_delete( :type data_center_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -273,22 +459,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -300,49 +478,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore def _create_update_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - data_center_name, # type: str - body, # type: "_models.DataCenterResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCenterResource" + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: "_models.DataCenterResource", + **kwargs: Any + ) -> "_models.DataCenterResource": cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCenterResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'DataCenterResource') + + request = build_create_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + data_center_name=data_center_name, + content_type=content_type, + json=_json, + template_url=self._create_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'DataCenterResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -360,17 +528,19 @@ def _create_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore + + @distributed_trace def begin_create_update( self, - resource_group_name, # type: str - cluster_name, # type: str - data_center_name, # type: str - body, # type: "_models.DataCenterResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataCenterResource"] + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: "_models.DataCenterResource", + **kwargs: Any + ) -> LROPoller["_models.DataCenterResource"]: """Create or update a managed Cassandra data center. When updating, overwrite all properties. To update only some properties, use PATCH. @@ -384,15 +554,19 @@ def begin_create_update( :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataCenterResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataCenterResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCenterResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -405,28 +579,21 @@ def begin_create_update( cluster_name=cluster_name, data_center_name=data_center_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DataCenterResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -438,49 +605,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - data_center_name, # type: str - body, # type: "_models.DataCenterResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCenterResource" + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: "_models.DataCenterResource", + **kwargs: Any + ) -> "_models.DataCenterResource": cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCenterResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'DataCenterResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + data_center_name=data_center_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'DataCenterResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -498,17 +655,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - cluster_name, # type: str - data_center_name, # type: str - body, # type: "_models.DataCenterResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataCenterResource"] + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: "_models.DataCenterResource", + **kwargs: Any + ) -> LROPoller["_models.DataCenterResource"]: """Update some of the properties of a managed Cassandra data center. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -521,15 +680,19 @@ def begin_update( :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataCenterResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataCenterResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCenterResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -542,28 +705,21 @@ def begin_update( cluster_name=cluster_name, data_center_name=data_center_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DataCenterResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - 'dataCenterName': self._serialize.url("data_center_name", data_center_name, 'str', max_length=100, min_length=1, pattern=r'^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -575,4 +731,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_resources_operations.py index 4d09074881373..19d4127c1e9e4 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_cassandra_resources_operations.py @@ -5,25 +5,656 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_cassandra_keyspaces_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_cassandra_keyspace_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_cassandra_keyspace_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_cassandra_keyspace_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_cassandra_keyspace_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_cassandra_keyspace_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_cassandra_keyspace_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_cassandra_keyspace_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_cassandra_tables_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_cassandra_table_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_cassandra_table_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_cassandra_table_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_cassandra_table_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_cassandra_table_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_cassandra_table_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_cassandra_table_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, 'str'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CassandraResourcesOperations(object): """CassandraResourcesOperations operations. @@ -47,13 +678,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_cassandra_keyspaces( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CassandraKeyspaceListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.CassandraKeyspaceListResult"]: """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. @@ -61,7 +692,8 @@ def list_cassandra_keyspaces( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CassandraKeyspaceListResult or the result of cls(response) + :return: An iterator like instance of either CassandraKeyspaceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,36 +702,33 @@ def list_cassandra_keyspaces( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_cassandra_keyspaces.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_cassandra_keyspaces_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_cassandra_keyspaces.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_cassandra_keyspaces_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CassandraKeyspaceListResult', pipeline_response) + deserialized = self._deserialize("CassandraKeyspaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,19 +746,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_cassandra_keyspaces.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces'} # type: ignore + @distributed_trace def get_cassandra_keyspace( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CassandraKeyspaceGetResults" + 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. @@ -149,28 +779,18 @@ def get_cassandra_keyspace( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_cassandra_keyspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_cassandra_keyspace_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self.get_cassandra_keyspace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -184,49 +804,40 @@ def get_cassandra_keyspace( return cls(pipeline_response, deserialized, {}) return deserialized + get_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore + def _create_update_cassandra_keyspace_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - create_update_cassandra_keyspace_parameters, # type: "_models.CassandraKeyspaceCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.CassandraKeyspaceGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + create_update_cassandra_keyspace_parameters: "_models.CassandraKeyspaceCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.CassandraKeyspaceGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CassandraKeyspaceGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_cassandra_keyspace_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_cassandra_keyspace_parameters, 'CassandraKeyspaceCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_cassandra_keyspace_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + content_type=content_type, + json=_json, + template_url=self._create_update_cassandra_keyspace_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_cassandra_keyspace_parameters, 'CassandraKeyspaceCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,17 +853,19 @@ def _create_update_cassandra_keyspace_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_cassandra_keyspace_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore + + @distributed_trace def begin_create_update_cassandra_keyspace( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - create_update_cassandra_keyspace_parameters, # type: "_models.CassandraKeyspaceCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CassandraKeyspaceGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + create_update_cassandra_keyspace_parameters: "_models.CassandraKeyspaceCreateUpdateParameters", + **kwargs: Any + ) -> 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. @@ -263,18 +876,23 @@ def begin_create_update_cassandra_keyspace( :type keyspace_name: str :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current Cassandra keyspace. - :type create_update_cassandra_keyspace_parameters: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters + :type create_update_cassandra_keyspace_parameters: + ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either CassandraKeyspaceGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CassandraKeyspaceGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -287,28 +905,21 @@ def begin_create_update_cassandra_keyspace( account_name=account_name, keyspace_name=keyspace_name, create_update_cassandra_keyspace_parameters=create_update_cassandra_keyspace_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CassandraKeyspaceGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -320,41 +931,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore def _delete_cassandra_keyspace_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_cassandra_keyspace_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_cassandra_keyspace_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self._delete_cassandra_keyspace_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -367,14 +970,15 @@ def _delete_cassandra_keyspace_initial( _delete_cassandra_keyspace_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore + + @distributed_trace def begin_delete_cassandra_keyspace( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -385,15 +989,17 @@ def begin_delete_cassandra_keyspace( :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -408,22 +1014,14 @@ def begin_delete_cassandra_keyspace( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -435,16 +1033,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}'} # type: ignore + @distributed_trace def get_cassandra_keyspace_throughput( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -464,28 +1063,18 @@ def get_cassandra_keyspace_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_cassandra_keyspace_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_cassandra_keyspace_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self.get_cassandra_keyspace_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -499,49 +1088,40 @@ def get_cassandra_keyspace_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_cassandra_keyspace_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default'} # type: ignore + def _update_cassandra_keyspace_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_cassandra_keyspace_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_cassandra_keyspace_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + content_type=content_type, + json=_json, + template_url=self._update_cassandra_keyspace_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -557,17 +1137,19 @@ def _update_cassandra_keyspace_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_cassandra_keyspace_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_cassandra_keyspace_throughput( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **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. @@ -578,18 +1160,23 @@ def begin_update_cassandra_keyspace_throughput( :type keyspace_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current Cassandra Keyspace. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -602,28 +1189,21 @@ def begin_update_cassandra_keyspace_throughput( account_name=account_name, keyspace_name=keyspace_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -635,43 +1215,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_cassandra_keyspace_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default'} # type: ignore def _migrate_cassandra_keyspace_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_cassandra_keyspace_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_cassandra_keyspace_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self._migrate_cassandra_keyspace_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -687,16 +1257,18 @@ def _migrate_cassandra_keyspace_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_cassandra_keyspace_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_cassandra_keyspace_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any + ) -> LROPoller["_models.ThroughputSettingsGetResults"]: """Migrate an Azure Cosmos DB Cassandra Keyspace from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -707,15 +1279,18 @@ def begin_migrate_cassandra_keyspace_to_autoscale( :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -730,25 +1305,17 @@ def begin_migrate_cassandra_keyspace_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -760,43 +1327,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_cassandra_keyspace_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_cassandra_keyspace_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_cassandra_keyspace_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_cassandra_keyspace_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self._migrate_cassandra_keyspace_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -812,16 +1369,18 @@ def _migrate_cassandra_keyspace_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_cassandra_keyspace_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_cassandra_keyspace_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any + ) -> LROPoller["_models.ThroughputSettingsGetResults"]: """Migrate an Azure Cosmos DB Cassandra Keyspace from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -832,15 +1391,18 @@ def begin_migrate_cassandra_keyspace_to_manual_throughput( :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -855,25 +1417,17 @@ def begin_migrate_cassandra_keyspace_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -885,16 +1439,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_cassandra_keyspace_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_cassandra_tables( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CassandraTableListResult"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + **kwargs: Any + ) -> Iterable["_models.CassandraTableListResult"]: """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. @@ -904,7 +1459,8 @@ def list_cassandra_tables( :param keyspace_name: Cosmos DB keyspace name. :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CassandraTableListResult or the result of cls(response) + :return: An iterator like instance of either CassandraTableListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -913,37 +1469,35 @@ def list_cassandra_tables( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_cassandra_tables.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_cassandra_tables_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=self.list_cassandra_tables.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_cassandra_tables_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CassandraTableListResult', pipeline_response) + deserialized = self._deserialize("CassandraTableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -961,20 +1515,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_cassandra_tables.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables'} # type: ignore + @distributed_trace def get_cassandra_table( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CassandraTableGetResults" + 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. @@ -995,29 +1550,19 @@ def get_cassandra_table( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_cassandra_table.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_cassandra_table_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self.get_cassandra_table.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1031,51 +1576,42 @@ def get_cassandra_table( return cls(pipeline_response, deserialized, {}) return deserialized + get_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore + def _create_update_cassandra_table_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - create_update_cassandra_table_parameters, # type: "_models.CassandraTableCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.CassandraTableGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: "_models.CassandraTableCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.CassandraTableGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CassandraTableGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_cassandra_table_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_cassandra_table_parameters, 'CassandraTableCreateUpdateParameters') + + request = build_create_update_cassandra_table_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + content_type=content_type, + json=_json, + template_url=self._create_update_cassandra_table_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_cassandra_table_parameters, 'CassandraTableCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1091,18 +1627,20 @@ def _create_update_cassandra_table_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_cassandra_table_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore + + @distributed_trace def begin_create_update_cassandra_table( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - create_update_cassandra_table_parameters, # type: "_models.CassandraTableCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CassandraTableGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: "_models.CassandraTableCreateUpdateParameters", + **kwargs: Any + ) -> 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. @@ -1115,18 +1653,23 @@ def begin_create_update_cassandra_table( :type table_name: str :param create_update_cassandra_table_parameters: The parameters to provide for the current Cassandra Table. - :type create_update_cassandra_table_parameters: ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters + :type create_update_cassandra_table_parameters: + ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either CassandraTableGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CassandraTableGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1140,29 +1683,21 @@ def begin_create_update_cassandra_table( keyspace_name=keyspace_name, table_name=table_name, create_update_cassandra_table_parameters=create_update_cassandra_table_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CassandraTableGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1174,43 +1709,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore def _delete_cassandra_table_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_cassandra_table_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_cassandra_table_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self._delete_cassandra_table_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1223,15 +1750,16 @@ def _delete_cassandra_table_initial( _delete_cassandra_table_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore + + @distributed_trace def begin_delete_cassandra_table( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1244,15 +1772,17 @@ def begin_delete_cassandra_table( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1268,23 +1798,14 @@ def begin_delete_cassandra_table( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1296,17 +1817,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}'} # type: ignore + @distributed_trace def get_cassandra_table_throughput( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -1328,29 +1850,19 @@ def get_cassandra_table_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_cassandra_table_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_cassandra_table_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self.get_cassandra_table_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1364,51 +1876,42 @@ def get_cassandra_table_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_cassandra_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default'} # type: ignore + def _update_cassandra_table_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_cassandra_table_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_cassandra_table_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + content_type=content_type, + json=_json, + template_url=self._update_cassandra_table_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1424,18 +1927,20 @@ def _update_cassandra_table_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_cassandra_table_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_cassandra_table_throughput( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> 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. @@ -1448,18 +1953,23 @@ def begin_update_cassandra_table_throughput( :type table_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current Cassandra table. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1473,29 +1983,21 @@ def begin_update_cassandra_table_throughput( keyspace_name=keyspace_name, table_name=table_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1507,45 +2009,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_cassandra_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default'} # type: ignore def _migrate_cassandra_table_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_cassandra_table_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_cassandra_table_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self._migrate_cassandra_table_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1561,17 +2053,19 @@ def _migrate_cassandra_table_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_cassandra_table_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_cassandra_table_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -1584,15 +2078,18 @@ def begin_migrate_cassandra_table_to_autoscale( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1608,26 +2105,17 @@ def begin_migrate_cassandra_table_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1639,45 +2127,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_cassandra_table_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_cassandra_table_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_cassandra_table_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_cassandra_table_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_name, + template_url=self._migrate_cassandra_table_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1693,17 +2171,19 @@ def _migrate_cassandra_table_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_cassandra_table_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_cassandra_table_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - keyspace_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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 autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1716,15 +2196,18 @@ def begin_migrate_cassandra_table_to_manual_throughput( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1740,26 +2223,17 @@ def begin_migrate_cassandra_table_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1771,4 +2245,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_cassandra_table_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_operations.py index c9075d618b173..6089314f183d2 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_operations.py @@ -5,23 +5,149 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_usages_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_metric_definitions_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CollectionOperations(object): """CollectionOperations operations. @@ -45,16 +171,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - collection_rid, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricListResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.MetricListResult"]: """Retrieves the metrics determined by the given filter for the given database account and collection. @@ -80,39 +206,39 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,21 +256,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics'} # type: ignore + @distributed_trace def list_usages( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - collection_rid, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UsagesResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.UsagesResult"]: """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. @@ -168,40 +295,39 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UsagesResult', pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -219,20 +345,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages'} # type: ignore + @distributed_trace def list_metric_definitions( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - collection_rid, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionsListResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionsListResult"]: """Retrieves metric definitions for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -244,7 +371,8 @@ def list_metric_definitions( :param collection_rid: Cosmos DB collection rid. :type collection_rid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionsListResult or the result of cls(response) + :return: An iterator like instance of either MetricDefinitionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -253,38 +381,37 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricDefinitionsListResult', pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -302,6 +429,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_partition_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_partition_operations.py index 282d8bd6afd09..a6419734fff48 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_partition_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_partition_operations.py @@ -5,23 +5,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_usages_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CollectionPartitionOperations(object): """CollectionPartitionOperations operations. @@ -45,16 +132,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - collection_rid, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PartitionMetricListResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.PartitionMetricListResult"]: """Retrieves the metrics determined by the given filter for the given collection, split by partition. @@ -71,7 +158,8 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionMetricListResult or the result of cls(response) + :return: An iterator like instance of either PartitionMetricListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -80,39 +168,39 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionMetricListResult', pipeline_response) + deserialized = self._deserialize("PartitionMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,21 +218,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics'} # type: ignore + @distributed_trace def list_usages( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - collection_rid, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PartitionUsagesResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PartitionUsagesResult"]: """Retrieves the usages (most recent storage data) for the given collection, split by partition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -159,7 +248,8 @@ def list_usages( supported parameter is name.value (name of the metric, can have an or of multiple names). :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionUsagesResult or the result of cls(response) + :return: An iterator like instance of either PartitionUsagesResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -168,40 +258,39 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionUsagesResult', pipeline_response) + deserialized = self._deserialize("PartitionUsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -219,6 +308,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_partition_region_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_partition_region_operations.py index a58acf2f517ae..14b22bdf1c319 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_partition_region_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_partition_region_operations.py @@ -5,23 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + region: str, + database_rid: str, + collection_rid: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "region": _SERIALIZER.url("region", region, 'str'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CollectionPartitionRegionOperations(object): """CollectionPartitionRegionOperations operations. @@ -45,17 +91,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - region, # type: str - database_rid, # type: str - collection_rid, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PartitionMetricListResult"] + resource_group_name: str, + account_name: str, + region: str, + database_rid: str, + collection_rid: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.PartitionMetricListResult"]: """Retrieves the metrics determined by the given filter for the given collection and region, split by partition. @@ -74,7 +120,8 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionMetricListResult or the result of cls(response) + :return: An iterator like instance of either PartitionMetricListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -83,40 +130,41 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'region': self._serialize.url("region", region, 'str'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionMetricListResult', pipeline_response) + deserialized = self._deserialize("PartitionMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -134,6 +182,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_region_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_region_operations.py index 0c6fb24445b87..05ba14abad84d 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_region_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_collection_region_operations.py @@ -5,23 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + region: str, + database_rid: str, + collection_rid: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "region": _SERIALIZER.url("region", region, 'str'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CollectionRegionOperations(object): """CollectionRegionOperations operations. @@ -45,17 +91,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - region, # type: str - database_rid, # type: str - collection_rid, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricListResult"] + resource_group_name: str, + account_name: str, + region: str, + database_rid: str, + collection_rid: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.MetricListResult"]: """Retrieves the metrics determined by the given filter for the given database account, collection and region. @@ -83,40 +129,41 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'region': self._serialize.url("region", region, 'str'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -134,6 +181,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_account_region_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_account_region_operations.py index 15ca6424a2ff8..d27020ed5c0ff 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_account_region_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_account_region_operations.py @@ -5,23 +5,65 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + region: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "region": _SERIALIZER.url("region", region, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseAccountRegionOperations(object): """DatabaseAccountRegionOperations operations. @@ -45,15 +87,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - region, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricListResult"] + resource_group_name: str, + account_name: str, + region: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.MetricListResult"]: """Retrieves the metrics determined by the given filter for the given database account and region. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -76,38 +118,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'region': self._serialize.url("region", region, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,6 +166,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_accounts_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_accounts_operations.py index 6b928c81a0a44..3ce466edc43b4 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_accounts_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_accounts_operations.py @@ -5,25 +5,693 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + 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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + 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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + 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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + 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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_failover_priority_change_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_connection_strings_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_offline_region_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_online_region_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_read_only_keys_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + 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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_read_only_keys_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + 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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_key_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_check_name_exists_request( + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}') + path_format_arguments = { + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_usages_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_metric_definitions_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseAccountsOperations(object): """DatabaseAccountsOperations operations. @@ -47,13 +715,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAccountGetResults" + 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. @@ -70,27 +738,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,47 +762,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore + def _update_initial( self, - resource_group_name, # type: str - account_name, # type: str - update_parameters, # type: "_models.DatabaseAccountUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAccountGetResults" + resource_group_name: str, + account_name: str, + update_parameters: "_models.DatabaseAccountUpdateParameters", + **kwargs: Any + ) -> "_models.DatabaseAccountGetResults": cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseAccountGetResults"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_parameters, 'DatabaseAccountUpdateParameters') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_parameters, 'DatabaseAccountUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,16 +807,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - account_name, # type: str - update_parameters, # type: "_models.DatabaseAccountUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DatabaseAccountGetResults"] + resource_group_name: str, + account_name: str, + update_parameters: "_models.DatabaseAccountUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.DatabaseAccountGetResults"]: """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. @@ -178,15 +829,19 @@ def begin_update( :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DatabaseAccountGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseAccountGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -198,27 +853,21 @@ def begin_update( resource_group_name=resource_group_name, account_name=account_name, update_parameters=update_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -230,47 +879,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - account_name, # type: str - create_update_parameters, # type: "_models.DatabaseAccountCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAccountGetResults" + resource_group_name: str, + account_name: str, + create_update_parameters: "_models.DatabaseAccountCreateUpdateParameters", + **kwargs: Any + ) -> "_models.DatabaseAccountGetResults": cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseAccountGetResults"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_parameters, 'DatabaseAccountCreateUpdateParameters') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_parameters, 'DatabaseAccountCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -284,16 +923,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - account_name, # type: str - create_update_parameters, # type: "_models.DatabaseAccountCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DatabaseAccountGetResults"] + resource_group_name: str, + account_name: str, + create_update_parameters: "_models.DatabaseAccountCreateUpdateParameters", + **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. @@ -302,18 +943,23 @@ def begin_create_or_update( :param account_name: Cosmos DB database account name. :type account_name: str :param create_update_parameters: The parameters to provide for the current database account. - :type create_update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DatabaseAccountGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseAccountGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -325,27 +971,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, account_name=account_name, create_update_parameters=create_update_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -357,39 +997,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -402,13 +1034,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -417,15 +1050,17 @@ def begin_delete( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -439,21 +1074,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -465,45 +1093,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'} # type: ignore def _failover_priority_change_initial( self, - resource_group_name, # type: str - account_name, # type: str - failover_parameters, # type: "_models.FailoverPolicies" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + failover_parameters: "_models.FailoverPolicies", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._failover_priority_change_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(failover_parameters, 'FailoverPolicies') + + request = build_failover_priority_change_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._failover_priority_change_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_parameters, 'FailoverPolicies') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -516,14 +1136,15 @@ def _failover_priority_change_initial( _failover_priority_change_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange'} # type: ignore + + @distributed_trace def begin_failover_priority_change( self, - resource_group_name, # type: str - account_name, # type: str - failover_parameters, # type: "_models.FailoverPolicies" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + failover_parameters: "_models.FailoverPolicies", + **kwargs: Any + ) -> LROPoller[None]: """Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the @@ -537,15 +1158,18 @@ def begin_failover_priority_change( :type failover_parameters: ~azure.mgmt.cosmosdb.models.FailoverPolicies :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -557,24 +1181,18 @@ def begin_failover_priority_change( resource_group_name=resource_group_name, account_name=account_name, failover_parameters=failover_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -586,17 +1204,19 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_failover_priority_change.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseAccountsListResult"] + **kwargs: Any + ) -> Iterable["_models.DatabaseAccountsListResult"]: """Lists all the Azure Cosmos DB database accounts available under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseAccountsListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseAccountsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -605,34 +1225,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseAccountsListResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -650,23 +1265,25 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatabaseAccountsListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseAccountsListResult"]: """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. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseAccountsListResult or the result of cls(response) + :return: An iterator like instance of either DatabaseAccountsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -675,35 +1292,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatabaseAccountsListResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -721,18 +1334,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts'} # type: ignore + @distributed_trace def list_keys( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAccountListKeysResult" + 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. @@ -749,27 +1363,17 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -783,15 +1387,17 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys'} # type: ignore + + @distributed_trace def list_connection_strings( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAccountListConnectionStringsResult" + 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. @@ -808,27 +1414,17 @@ def list_connection_strings( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.list_connection_strings.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_connection_strings_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_connection_strings.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -842,68 +1438,59 @@ def list_connection_strings( return cls(pipeline_response, deserialized, {}) return deserialized + list_connection_strings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings'} # type: ignore + def _offline_region_initial( self, - resource_group_name, # type: str - account_name, # type: str - region_parameter_for_offline, # type: "_models.RegionForOnlineOffline" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + region_parameter_for_offline: "_models.RegionForOnlineOffline", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._offline_region_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(region_parameter_for_offline, 'RegionForOnlineOffline') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_offline_region_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._offline_region_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(region_parameter_for_offline, 'RegionForOnlineOffline') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _offline_region_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion'} # type: ignore + + @distributed_trace def begin_offline_region( self, - resource_group_name, # type: str - account_name, # type: str - region_parameter_for_offline, # type: "_models.RegionForOnlineOffline" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + region_parameter_for_offline: "_models.RegionForOnlineOffline", + **kwargs: Any + ) -> LROPoller[None]: """Offline the specified region for the specified Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -914,15 +1501,18 @@ def begin_offline_region( :type region_parameter_for_offline: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -934,24 +1524,18 @@ def begin_offline_region( resource_group_name=resource_group_name, account_name=account_name, region_parameter_for_offline=region_parameter_for_offline, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -963,68 +1547,58 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_offline_region.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion'} # type: ignore def _online_region_initial( self, - resource_group_name, # type: str - account_name, # type: str - region_parameter_for_online, # type: "_models.RegionForOnlineOffline" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + region_parameter_for_online: "_models.RegionForOnlineOffline", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._online_region_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(region_parameter_for_online, 'RegionForOnlineOffline') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_online_region_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._online_region_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(region_parameter_for_online, 'RegionForOnlineOffline') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _online_region_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion'} # type: ignore + + @distributed_trace def begin_online_region( self, - resource_group_name, # type: str - account_name, # type: str - region_parameter_for_online, # type: "_models.RegionForOnlineOffline" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + region_parameter_for_online: "_models.RegionForOnlineOffline", + **kwargs: Any + ) -> LROPoller[None]: """Online the specified region for the specified Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1035,15 +1609,18 @@ def begin_online_region( :type region_parameter_for_online: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1055,24 +1632,18 @@ def begin_online_region( resource_group_name=resource_group_name, account_name=account_name, region_parameter_for_online=region_parameter_for_online, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1084,15 +1655,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_online_region.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion'} # type: ignore + @distributed_trace def get_read_only_keys( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAccountListReadOnlyKeysResult" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.DatabaseAccountListReadOnlyKeysResult": """Lists the read-only 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. @@ -1109,27 +1681,17 @@ def get_read_only_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_read_only_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_read_only_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get_read_only_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1143,15 +1705,17 @@ def get_read_only_keys( return cls(pipeline_response, deserialized, {}) return deserialized + get_read_only_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys'} # type: ignore + + @distributed_trace def list_read_only_keys( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DatabaseAccountListReadOnlyKeysResult" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.DatabaseAccountListReadOnlyKeysResult": """Lists the read-only 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. @@ -1168,27 +1732,17 @@ def list_read_only_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.list_read_only_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_read_only_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_read_only_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1202,45 +1756,38 @@ def list_read_only_keys( return cls(pipeline_response, deserialized, {}) return deserialized + list_read_only_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys'} # type: ignore + def _regenerate_key_initial( self, - resource_group_name, # type: str - account_name, # type: str - key_to_regenerate, # type: "_models.DatabaseAccountRegenerateKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + key_to_regenerate: "_models.DatabaseAccountRegenerateKeyParameters", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._regenerate_key_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(key_to_regenerate, 'DatabaseAccountRegenerateKeyParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_regenerate_key_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._regenerate_key_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(key_to_regenerate, 'DatabaseAccountRegenerateKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1253,14 +1800,15 @@ def _regenerate_key_initial( _regenerate_key_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey'} # type: ignore + + @distributed_trace def begin_regenerate_key( self, - resource_group_name, # type: str - account_name, # type: str - key_to_regenerate, # type: "_models.DatabaseAccountRegenerateKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + key_to_regenerate: "_models.DatabaseAccountRegenerateKeyParameters", + **kwargs: Any + ) -> LROPoller[None]: """Regenerates an access key for the specified Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1271,15 +1819,18 @@ def begin_regenerate_key( :type key_to_regenerate: ~azure.mgmt.cosmosdb.models.DatabaseAccountRegenerateKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1291,24 +1842,18 @@ def begin_regenerate_key( resource_group_name=resource_group_name, account_name=account_name, key_to_regenerate=key_to_regenerate, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1320,14 +1865,15 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey'} # type: ignore + @distributed_trace def check_name_exists( self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -1344,23 +1890,15 @@ def check_name_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self.check_name_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_name_exists_request( + account_name=account_name, + template_url=self.check_name_exists.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1370,18 +1908,19 @@ def check_name_exists( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_name_exists.metadata = {'url': '/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}'} # type: ignore + + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricListResult"] + resource_group_name: str, + account_name: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.MetricListResult"]: """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. @@ -1402,37 +1941,35 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1450,19 +1987,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics'} # type: ignore + @distributed_trace def list_usages( self, - resource_group_name, # type: str - account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UsagesResult"] + resource_group_name: str, + account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.UsagesResult"]: """Retrieves the usages (most recent data) for the given database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1482,38 +2020,35 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UsagesResult', pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1531,18 +2066,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages'} # type: ignore + @distributed_trace def list_metric_definitions( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionsListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionsListResult"]: """Retrieves metric definitions for the given database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1550,7 +2086,8 @@ def list_metric_definitions( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionsListResult or the result of cls(response) + :return: An iterator like instance of either MetricDefinitionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -1559,36 +2096,33 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricDefinitionsListResult', pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1606,6 +2140,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_operations.py index 82421f7d6ffab..db8aa5b2901fa 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_database_operations.py @@ -5,23 +5,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_usages_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_metric_definitions_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatabaseOperations(object): """DatabaseOperations operations. @@ -45,15 +165,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricListResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.MetricListResult"]: """Retrieves the metrics determined by the given filter for the given database account and database. @@ -77,38 +197,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricListResult', pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,20 +245,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics'} # type: ignore + @distributed_trace def list_usages( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UsagesResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.UsagesResult"]: """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. @@ -161,39 +281,37 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_usages_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UsagesResult', pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -211,19 +329,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages'} # type: ignore + @distributed_trace def list_metric_definitions( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionsListResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionsListResult"]: """Retrieves metric definitions for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -233,7 +352,8 @@ def list_metric_definitions( :param database_rid: Cosmos DB database rid. :type database_rid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionsListResult or the result of cls(response) + :return: An iterator like instance of either MetricDefinitionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -242,37 +362,35 @@ def list_metric_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metric_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + template_url=self.list_metric_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metric_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MetricDefinitionsListResult', pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -290,6 +408,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_gremlin_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_gremlin_resources_operations.py index 79a90859cc767..5fd1bdd4d5353 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_gremlin_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_gremlin_resources_operations.py @@ -5,25 +5,656 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_gremlin_databases_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_gremlin_database_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_gremlin_database_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_gremlin_database_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_gremlin_database_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_gremlin_database_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_gremlin_database_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_gremlin_database_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_gremlin_graphs_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_gremlin_graph_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "graphName": _SERIALIZER.url("graph_name", graph_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_gremlin_graph_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "graphName": _SERIALIZER.url("graph_name", graph_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_gremlin_graph_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "graphName": _SERIALIZER.url("graph_name", graph_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_gremlin_graph_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "graphName": _SERIALIZER.url("graph_name", graph_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_gremlin_graph_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "graphName": _SERIALIZER.url("graph_name", graph_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_gremlin_graph_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "graphName": _SERIALIZER.url("graph_name", graph_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_gremlin_graph_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "graphName": _SERIALIZER.url("graph_name", graph_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class GremlinResourcesOperations(object): """GremlinResourcesOperations operations. @@ -47,13 +678,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_gremlin_databases( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GremlinDatabaseListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.GremlinDatabaseListResult"]: """Lists the Gremlin databases under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -61,7 +692,8 @@ def list_gremlin_databases( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GremlinDatabaseListResult or the result of cls(response) + :return: An iterator like instance of either GremlinDatabaseListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,36 +702,33 @@ def list_gremlin_databases( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_gremlin_databases.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_gremlin_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_gremlin_databases.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_gremlin_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GremlinDatabaseListResult', pipeline_response) + deserialized = self._deserialize("GremlinDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,19 +746,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_gremlin_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases'} # type: ignore + @distributed_trace def get_gremlin_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GremlinDatabaseGetResults" + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.GremlinDatabaseGetResults": """Gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided name. @@ -149,28 +779,18 @@ def get_gremlin_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_gremlin_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_gremlin_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_gremlin_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -184,49 +804,40 @@ def get_gremlin_database( return cls(pipeline_response, deserialized, {}) return deserialized + get_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore + def _create_update_gremlin_database_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - create_update_gremlin_database_parameters, # type: "_models.GremlinDatabaseCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.GremlinDatabaseGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + create_update_gremlin_database_parameters: "_models.GremlinDatabaseCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.GremlinDatabaseGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GremlinDatabaseGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_gremlin_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_gremlin_database_parameters, 'GremlinDatabaseCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_gremlin_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._create_update_gremlin_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_gremlin_database_parameters, 'GremlinDatabaseCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,17 +853,19 @@ def _create_update_gremlin_database_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_gremlin_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore + + @distributed_trace def begin_create_update_gremlin_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - create_update_gremlin_database_parameters, # type: "_models.GremlinDatabaseCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.GremlinDatabaseGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + create_update_gremlin_database_parameters: "_models.GremlinDatabaseCreateUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.GremlinDatabaseGetResults"]: """Create or update an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -263,18 +876,23 @@ def begin_create_update_gremlin_database( :type database_name: str :param create_update_gremlin_database_parameters: The parameters to provide for the current Gremlin database. - :type create_update_gremlin_database_parameters: ~azure.mgmt.cosmosdb.models.GremlinDatabaseCreateUpdateParameters + :type create_update_gremlin_database_parameters: + ~azure.mgmt.cosmosdb.models.GremlinDatabaseCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either GremlinDatabaseGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GremlinDatabaseGetResults or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GremlinDatabaseGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -287,28 +905,21 @@ def begin_create_update_gremlin_database( account_name=account_name, database_name=database_name, create_update_gremlin_database_parameters=create_update_gremlin_database_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GremlinDatabaseGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -320,41 +931,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore def _delete_gremlin_database_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_gremlin_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_gremlin_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._delete_gremlin_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -367,14 +970,15 @@ def _delete_gremlin_database_initial( _delete_gremlin_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore + + @distributed_trace def begin_delete_gremlin_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -385,15 +989,17 @@ def begin_delete_gremlin_database( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -408,22 +1014,14 @@ def begin_delete_gremlin_database( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -435,16 +1033,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}'} # type: ignore + @distributed_trace def get_gremlin_database_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -464,28 +1063,18 @@ def get_gremlin_database_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_gremlin_database_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_gremlin_database_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_gremlin_database_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -499,49 +1088,40 @@ def get_gremlin_database_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_gremlin_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default'} # type: ignore + def _update_gremlin_database_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_gremlin_database_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_gremlin_database_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._update_gremlin_database_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -557,17 +1137,19 @@ def _update_gremlin_database_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_gremlin_database_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_gremlin_database_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.ThroughputSettingsGetResults"]: """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. @@ -578,18 +1160,23 @@ def begin_update_gremlin_database_throughput( :type database_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current Gremlin database. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -602,28 +1189,21 @@ def begin_update_gremlin_database_throughput( account_name=account_name, database_name=database_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -635,43 +1215,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_gremlin_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default'} # type: ignore def _migrate_gremlin_database_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_gremlin_database_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_gremlin_database_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_gremlin_database_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -687,16 +1257,18 @@ def _migrate_gremlin_database_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_gremlin_database_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_gremlin_database_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -707,15 +1279,18 @@ def begin_migrate_gremlin_database_to_autoscale( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -730,25 +1305,17 @@ def begin_migrate_gremlin_database_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -760,43 +1327,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_gremlin_database_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_gremlin_database_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_gremlin_database_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_gremlin_database_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_gremlin_database_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -812,16 +1369,18 @@ def _migrate_gremlin_database_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_gremlin_database_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_gremlin_database_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -832,15 +1391,18 @@ def begin_migrate_gremlin_database_to_manual_throughput( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -855,25 +1417,17 @@ def begin_migrate_gremlin_database_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -885,16 +1439,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_gremlin_database_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_gremlin_graphs( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GremlinGraphListResult"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.GremlinGraphListResult"]: """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. @@ -904,7 +1459,8 @@ def list_gremlin_graphs( :param database_name: Cosmos DB database name. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GremlinGraphListResult or the result of cls(response) + :return: An iterator like instance of either GremlinGraphListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -913,37 +1469,35 @@ def list_gremlin_graphs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_gremlin_graphs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_gremlin_graphs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.list_gremlin_graphs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_gremlin_graphs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GremlinGraphListResult', pipeline_response) + deserialized = self._deserialize("GremlinGraphListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -961,20 +1515,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_gremlin_graphs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs'} # type: ignore + @distributed_trace def get_gremlin_graph( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GremlinGraphGetResults" + 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. @@ -995,29 +1550,19 @@ def get_gremlin_graph( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_gremlin_graph.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_gremlin_graph_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self.get_gremlin_graph.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1031,51 +1576,42 @@ def get_gremlin_graph( return cls(pipeline_response, deserialized, {}) return deserialized + get_gremlin_graph.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore + def _create_update_gremlin_graph_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - create_update_gremlin_graph_parameters, # type: "_models.GremlinGraphCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.GremlinGraphGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + create_update_gremlin_graph_parameters: "_models.GremlinGraphCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.GremlinGraphGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GremlinGraphGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_gremlin_graph_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_gremlin_graph_parameters, 'GremlinGraphCreateUpdateParameters') + + request = build_create_update_gremlin_graph_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + content_type=content_type, + json=_json, + template_url=self._create_update_gremlin_graph_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_gremlin_graph_parameters, 'GremlinGraphCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1091,18 +1627,20 @@ def _create_update_gremlin_graph_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_gremlin_graph_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore + + @distributed_trace def begin_create_update_gremlin_graph( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - create_update_gremlin_graph_parameters, # type: "_models.GremlinGraphCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.GremlinGraphGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + create_update_gremlin_graph_parameters: "_models.GremlinGraphCreateUpdateParameters", + **kwargs: Any + ) -> 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. @@ -1115,18 +1653,23 @@ def begin_create_update_gremlin_graph( :type graph_name: str :param create_update_gremlin_graph_parameters: The parameters to provide for the current Gremlin graph. - :type create_update_gremlin_graph_parameters: ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters + :type create_update_gremlin_graph_parameters: + ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either GremlinGraphGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GremlinGraphGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1140,29 +1683,21 @@ def begin_create_update_gremlin_graph( database_name=database_name, graph_name=graph_name, create_update_gremlin_graph_parameters=create_update_gremlin_graph_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GremlinGraphGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1174,43 +1709,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_gremlin_graph.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore def _delete_gremlin_graph_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_gremlin_graph_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_gremlin_graph_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self._delete_gremlin_graph_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1223,15 +1750,16 @@ def _delete_gremlin_graph_initial( _delete_gremlin_graph_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore + + @distributed_trace def begin_delete_gremlin_graph( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + 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. @@ -1244,15 +1772,17 @@ def begin_delete_gremlin_graph( :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1268,23 +1798,14 @@ def begin_delete_gremlin_graph( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1296,17 +1817,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_gremlin_graph.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}'} # type: ignore + @distributed_trace def get_gremlin_graph_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -1328,29 +1850,19 @@ def get_gremlin_graph_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_gremlin_graph_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_gremlin_graph_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self.get_gremlin_graph_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1364,51 +1876,42 @@ def get_gremlin_graph_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_gremlin_graph_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default'} # type: ignore + def _update_gremlin_graph_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_gremlin_graph_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_gremlin_graph_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + content_type=content_type, + json=_json, + template_url=self._update_gremlin_graph_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1424,18 +1927,20 @@ def _update_gremlin_graph_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_gremlin_graph_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_gremlin_graph_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> 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. @@ -1448,18 +1953,23 @@ def begin_update_gremlin_graph_throughput( :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current Gremlin graph. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1473,29 +1983,21 @@ def begin_update_gremlin_graph_throughput( database_name=database_name, graph_name=graph_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1507,45 +2009,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_gremlin_graph_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default'} # type: ignore def _migrate_gremlin_graph_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_gremlin_graph_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_gremlin_graph_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self._migrate_gremlin_graph_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1561,17 +2053,19 @@ def _migrate_gremlin_graph_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_gremlin_graph_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_gremlin_graph_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any + ) -> 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. @@ -1584,15 +2078,18 @@ def begin_migrate_gremlin_graph_to_autoscale( :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1608,26 +2105,17 @@ def begin_migrate_gremlin_graph_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1639,45 +2127,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_gremlin_graph_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_gremlin_graph_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_gremlin_graph_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_gremlin_graph_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + template_url=self._migrate_gremlin_graph_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1693,17 +2171,19 @@ def _migrate_gremlin_graph_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_gremlin_graph_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_gremlin_graph_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - graph_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + **kwargs: Any + ) -> 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. @@ -1716,15 +2196,18 @@ def begin_migrate_gremlin_graph_to_manual_throughput( :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1740,26 +2223,17 @@ def begin_migrate_gremlin_graph_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'graphName': self._serialize.url("graph_name", graph_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1771,4 +2245,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_gremlin_graph_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_locations_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_locations_operations.py index 84b98dd18aa01..3939fcae313be 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_locations_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_locations_operations.py @@ -5,23 +5,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + location: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LocationsOperations(object): """LocationsOperations operations. @@ -45,11 +111,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LocationListResult"] + **kwargs: Any + ) -> Iterable["_models.LocationListResult"]: """List Cosmos DB locations and their properties. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,34 +128,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,17 +168,18 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations'} # type: ignore + @distributed_trace def get( self, - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.LocationGetResult" + location: str, + **kwargs: Any + ) -> "_models.LocationGetResult": """Get the properties of an existing Cosmos DB location. :param location: Cosmos DB region, with spaces between words and each word capitalized. @@ -132,26 +194,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,4 +217,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}'} # type: ignore + diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_mongo_db_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_mongo_db_resources_operations.py index f5b1d7b592ce7..40cb4882dc8bc 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_mongo_db_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_mongo_db_resources_operations.py @@ -5,25 +5,704 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_mongo_db_databases_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_mongo_db_database_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_mongo_db_database_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_mongo_db_database_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_mongo_db_database_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_mongo_db_database_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_mongo_db_database_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_mongo_db_database_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_mongo_db_collections_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_mongo_db_collection_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_mongo_db_collection_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_mongo_db_collection_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_mongo_db_collection_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_mongo_db_collection_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_mongo_db_collection_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_mongo_db_collection_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_retrieve_continuous_backup_information_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class MongoDBResourcesOperations(object): """MongoDBResourcesOperations operations. @@ -47,13 +726,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_mongo_db_databases( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MongoDBDatabaseListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.MongoDBDatabaseListResult"]: """Lists the MongoDB databases under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -61,7 +740,8 @@ def list_mongo_db_databases( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MongoDBDatabaseListResult or the result of cls(response) + :return: An iterator like instance of either MongoDBDatabaseListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoDBDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,36 +750,33 @@ def list_mongo_db_databases( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_mongo_db_databases.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_mongo_db_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_mongo_db_databases.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_mongo_db_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MongoDBDatabaseListResult', pipeline_response) + deserialized = self._deserialize("MongoDBDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,19 +794,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_mongo_db_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases'} # type: ignore + @distributed_trace def get_mongo_db_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MongoDBDatabaseGetResults" + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.MongoDBDatabaseGetResults": """Gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided name. @@ -149,28 +827,18 @@ def get_mongo_db_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_mongo_db_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_mongo_db_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_mongo_db_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -184,49 +852,40 @@ def get_mongo_db_database( return cls(pipeline_response, deserialized, {}) return deserialized + get_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore + def _create_update_mongo_db_database_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - create_update_mongo_db_database_parameters, # type: "_models.MongoDBDatabaseCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MongoDBDatabaseGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + create_update_mongo_db_database_parameters: "_models.MongoDBDatabaseCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.MongoDBDatabaseGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MongoDBDatabaseGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_mongo_db_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_mongo_db_database_parameters, 'MongoDBDatabaseCreateUpdateParameters') + + request = build_create_update_mongo_db_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._create_update_mongo_db_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_mongo_db_database_parameters, 'MongoDBDatabaseCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,17 +901,19 @@ def _create_update_mongo_db_database_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_mongo_db_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore + + @distributed_trace def begin_create_update_mongo_db_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - create_update_mongo_db_database_parameters, # type: "_models.MongoDBDatabaseCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MongoDBDatabaseGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + create_update_mongo_db_database_parameters: "_models.MongoDBDatabaseCreateUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.MongoDBDatabaseGetResults"]: """Create or updates Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -263,18 +924,23 @@ def begin_create_update_mongo_db_database( :type database_name: str :param create_update_mongo_db_database_parameters: The parameters to provide for the current MongoDB database. - :type create_update_mongo_db_database_parameters: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseCreateUpdateParameters + :type create_update_mongo_db_database_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBDatabaseCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MongoDBDatabaseGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MongoDBDatabaseGetResults or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MongoDBDatabaseGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -287,28 +953,21 @@ def begin_create_update_mongo_db_database( account_name=account_name, database_name=database_name, create_update_mongo_db_database_parameters=create_update_mongo_db_database_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MongoDBDatabaseGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -320,41 +979,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore def _delete_mongo_db_database_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_mongo_db_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_mongo_db_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._delete_mongo_db_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -367,14 +1018,15 @@ def _delete_mongo_db_database_initial( _delete_mongo_db_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore + + @distributed_trace def begin_delete_mongo_db_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -385,15 +1037,17 @@ def begin_delete_mongo_db_database( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -408,22 +1062,14 @@ def begin_delete_mongo_db_database( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -435,16 +1081,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}'} # type: ignore + @distributed_trace def get_mongo_db_database_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -464,28 +1111,18 @@ def get_mongo_db_database_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_mongo_db_database_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_mongo_db_database_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_mongo_db_database_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -499,49 +1136,40 @@ def get_mongo_db_database_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_mongo_db_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default'} # type: ignore + def _update_mongo_db_database_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_mongo_db_database_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_mongo_db_database_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._update_mongo_db_database_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -557,17 +1185,19 @@ def _update_mongo_db_database_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_mongo_db_database_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_mongo_db_database_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> 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. @@ -578,18 +1208,23 @@ def begin_update_mongo_db_database_throughput( :type database_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current MongoDB database. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -602,28 +1237,21 @@ def begin_update_mongo_db_database_throughput( account_name=account_name, database_name=database_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -635,43 +1263,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_mongo_db_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default'} # type: ignore def _migrate_mongo_db_database_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_mongo_db_database_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_mongo_db_database_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_mongo_db_database_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -687,16 +1305,18 @@ def _migrate_mongo_db_database_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_mongo_db_database_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_mongo_db_database_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -707,15 +1327,18 @@ def begin_migrate_mongo_db_database_to_autoscale( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -730,25 +1353,17 @@ def begin_migrate_mongo_db_database_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -760,43 +1375,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_mongo_db_database_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_mongo_db_database_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_mongo_db_database_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_mongo_db_database_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_mongo_db_database_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -812,16 +1417,18 @@ def _migrate_mongo_db_database_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_mongo_db_database_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_mongo_db_database_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -832,15 +1439,18 @@ def begin_migrate_mongo_db_database_to_manual_throughput( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -855,25 +1465,17 @@ def begin_migrate_mongo_db_database_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -885,16 +1487,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_mongo_db_database_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_mongo_db_collections( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MongoDBCollectionListResult"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.MongoDBCollectionListResult"]: """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. @@ -904,7 +1507,8 @@ def list_mongo_db_collections( :param database_name: Cosmos DB database name. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MongoDBCollectionListResult or the result of cls(response) + :return: An iterator like instance of either MongoDBCollectionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -913,37 +1517,35 @@ def list_mongo_db_collections( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_mongo_db_collections.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_mongo_db_collections_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.list_mongo_db_collections.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_mongo_db_collections_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MongoDBCollectionListResult', pipeline_response) + deserialized = self._deserialize("MongoDBCollectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -961,20 +1563,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_mongo_db_collections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections'} # type: ignore + @distributed_trace def get_mongo_db_collection( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MongoDBCollectionGetResults" + 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. @@ -995,29 +1598,19 @@ def get_mongo_db_collection( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_mongo_db_collection.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_mongo_db_collection_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self.get_mongo_db_collection.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1031,51 +1624,42 @@ def get_mongo_db_collection( return cls(pipeline_response, deserialized, {}) return deserialized + get_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore + def _create_update_mongo_db_collection_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - create_update_mongo_db_collection_parameters, # type: "_models.MongoDBCollectionCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MongoDBCollectionGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + create_update_mongo_db_collection_parameters: "_models.MongoDBCollectionCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.MongoDBCollectionGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MongoDBCollectionGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_mongo_db_collection_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_mongo_db_collection_parameters, 'MongoDBCollectionCreateUpdateParameters') + + request = build_create_update_mongo_db_collection_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + content_type=content_type, + json=_json, + template_url=self._create_update_mongo_db_collection_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_mongo_db_collection_parameters, 'MongoDBCollectionCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1091,18 +1675,20 @@ def _create_update_mongo_db_collection_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_mongo_db_collection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore + + @distributed_trace def begin_create_update_mongo_db_collection( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - create_update_mongo_db_collection_parameters, # type: "_models.MongoDBCollectionCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MongoDBCollectionGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + create_update_mongo_db_collection_parameters: "_models.MongoDBCollectionCreateUpdateParameters", + **kwargs: Any + ) -> 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. @@ -1115,18 +1701,23 @@ def begin_create_update_mongo_db_collection( :type collection_name: str :param create_update_mongo_db_collection_parameters: The parameters to provide for the current MongoDB Collection. - :type create_update_mongo_db_collection_parameters: ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters + :type create_update_mongo_db_collection_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MongoDBCollectionGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MongoDBCollectionGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1140,29 +1731,21 @@ def begin_create_update_mongo_db_collection( database_name=database_name, collection_name=collection_name, create_update_mongo_db_collection_parameters=create_update_mongo_db_collection_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MongoDBCollectionGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1174,43 +1757,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore def _delete_mongo_db_collection_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_mongo_db_collection_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_mongo_db_collection_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self._delete_mongo_db_collection_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1223,15 +1798,16 @@ def _delete_mongo_db_collection_initial( _delete_mongo_db_collection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore + + @distributed_trace def begin_delete_mongo_db_collection( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + 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. @@ -1244,15 +1820,17 @@ def begin_delete_mongo_db_collection( :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1268,23 +1846,14 @@ def begin_delete_mongo_db_collection( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1296,17 +1865,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}'} # type: ignore + @distributed_trace def get_mongo_db_collection_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -1328,29 +1898,19 @@ def get_mongo_db_collection_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_mongo_db_collection_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_mongo_db_collection_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self.get_mongo_db_collection_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1364,51 +1924,42 @@ def get_mongo_db_collection_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_mongo_db_collection_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default'} # type: ignore + def _update_mongo_db_collection_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_mongo_db_collection_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_mongo_db_collection_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + content_type=content_type, + json=_json, + template_url=self._update_mongo_db_collection_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1424,18 +1975,20 @@ def _update_mongo_db_collection_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_mongo_db_collection_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_mongo_db_collection_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **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. @@ -1448,18 +2001,23 @@ def begin_update_mongo_db_collection_throughput( :type collection_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the current MongoDB collection. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1473,29 +2031,21 @@ def begin_update_mongo_db_collection_throughput( database_name=database_name, collection_name=collection_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1507,45 +2057,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_mongo_db_collection_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default'} # type: ignore def _migrate_mongo_db_collection_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_mongo_db_collection_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_mongo_db_collection_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self._migrate_mongo_db_collection_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1561,17 +2101,19 @@ def _migrate_mongo_db_collection_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_mongo_db_collection_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_mongo_db_collection_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -1584,15 +2126,18 @@ def begin_migrate_mongo_db_collection_to_autoscale( :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1608,26 +2153,17 @@ def begin_migrate_mongo_db_collection_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1639,45 +2175,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_mongo_db_collection_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_mongo_db_collection_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_mongo_db_collection_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_mongo_db_collection_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + template_url=self._migrate_mongo_db_collection_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1693,17 +2219,19 @@ def _migrate_mongo_db_collection_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_mongo_db_collection_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_mongo_db_collection_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -1716,15 +2244,18 @@ def begin_migrate_mongo_db_collection_to_manual_throughput( :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1740,26 +2271,17 @@ def begin_migrate_mongo_db_collection_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1771,51 +2293,41 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_mongo_db_collection_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore def _retrieve_continuous_backup_information_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - location, # type: "_models.ContinuousBackupRestoreLocation" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BackupInformation"] + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + location: "_models.ContinuousBackupRestoreLocation", + **kwargs: Any + ) -> Optional["_models.BackupInformation"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BackupInformation"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._retrieve_continuous_backup_information_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_retrieve_continuous_backup_information_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + content_type=content_type, + json=_json, + template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(location, 'ContinuousBackupRestoreLocation') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1831,18 +2343,20 @@ def _retrieve_continuous_backup_information_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _retrieve_continuous_backup_information_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation'} # type: ignore + + @distributed_trace def begin_retrieve_continuous_backup_information( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - collection_name, # type: str - location, # type: "_models.ContinuousBackupRestoreLocation" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BackupInformation"] + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + location: "_models.ContinuousBackupRestoreLocation", + **kwargs: Any + ) -> 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. @@ -1857,15 +2371,19 @@ def begin_retrieve_continuous_backup_information( :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BackupInformation or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInformation"] lro_delay = kwargs.pop( 'polling_interval', @@ -1879,29 +2397,21 @@ def begin_retrieve_continuous_backup_information( database_name=database_name, collection_name=collection_name, location=location, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BackupInformation', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1913,4 +2423,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_retrieve_continuous_backup_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_notebook_workspaces_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_notebook_workspaces_operations.py index 00d9e6fc86d8f..79c29063b621c 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_notebook_workspaces_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_notebook_workspaces_operations.py @@ -5,25 +5,294 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_database_account_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "notebookWorkspaceName": _SERIALIZER.url("notebook_workspace_name", notebook_workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "notebookWorkspaceName": _SERIALIZER.url("notebook_workspace_name", notebook_workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "notebookWorkspaceName": _SERIALIZER.url("notebook_workspace_name", notebook_workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_connection_info_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "notebookWorkspaceName": _SERIALIZER.url("notebook_workspace_name", notebook_workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_auth_token_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "notebookWorkspaceName": _SERIALIZER.url("notebook_workspace_name", notebook_workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_start_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "notebookWorkspaceName": _SERIALIZER.url("notebook_workspace_name", notebook_workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class NotebookWorkspacesOperations(object): """NotebookWorkspacesOperations operations. @@ -47,13 +316,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database_account( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NotebookWorkspaceListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.NotebookWorkspaceListResult"]: """Gets the notebook workspace resources of an existing Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -61,7 +330,8 @@ def list_by_database_account( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NotebookWorkspaceListResult or the result of cls(response) + :return: An iterator like instance of either NotebookWorkspaceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.NotebookWorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,36 +340,33 @@ def list_by_database_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_by_database_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NotebookWorkspaceListResult', pipeline_response) + deserialized = self._deserialize("NotebookWorkspaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,25 +379,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) list_by_database_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.NotebookWorkspace" + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any + ) -> "_models.NotebookWorkspace": """Gets the notebook workspace for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -149,34 +417,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NotebookWorkspace', pipeline_response) @@ -185,56 +443,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - notebook_create_update_parameters, # type: "_models.NotebookWorkspaceCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.NotebookWorkspace" + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + notebook_create_update_parameters: "_models.NotebookWorkspaceCreateUpdateParameters", + **kwargs: Any + ) -> "_models.NotebookWorkspace": cls = kwargs.pop('cls', None) # type: ClsType["_models.NotebookWorkspace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(notebook_create_update_parameters, 'NotebookWorkspaceCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(notebook_create_update_parameters, 'NotebookWorkspaceCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('NotebookWorkspace', pipeline_response) @@ -242,17 +490,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - notebook_create_update_parameters, # type: "_models.NotebookWorkspaceCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.NotebookWorkspace"] + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + notebook_create_update_parameters: "_models.NotebookWorkspaceCreateUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.NotebookWorkspace"]: """Creates the notebook workspace for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -263,18 +513,23 @@ def begin_create_or_update( :type notebook_workspace_name: str or ~azure.mgmt.cosmosdb.models.NotebookWorkspaceName :param notebook_create_update_parameters: The notebook workspace to create for the current database account. - :type notebook_create_update_parameters: ~azure.mgmt.cosmosdb.models.NotebookWorkspaceCreateUpdateParameters + :type notebook_create_update_parameters: + ~azure.mgmt.cosmosdb.models.NotebookWorkspaceCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either NotebookWorkspace or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either NotebookWorkspace or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.NotebookWorkspace] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.NotebookWorkspace"] lro_delay = kwargs.pop( 'polling_interval', @@ -287,28 +542,21 @@ def begin_create_or_update( account_name=account_name, notebook_workspace_name=notebook_workspace_name, notebook_create_update_parameters=notebook_create_update_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('NotebookWorkspace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -320,64 +568,54 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any + ) -> LROPoller[None]: """Deletes the notebook workspace for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -388,15 +626,17 @@ def begin_delete( :type notebook_workspace_name: str or ~azure.mgmt.cosmosdb.models.NotebookWorkspaceName :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -411,22 +651,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -438,16 +670,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}'} # type: ignore + @distributed_trace def list_connection_info( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.NotebookWorkspaceConnectionInfoResult" + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any + ) -> "_models.NotebookWorkspaceConnectionInfoResult": """Retrieves the connection info for the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -466,34 +699,24 @@ def list_connection_info( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.list_connection_info.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_connection_info_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self.list_connection_info.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NotebookWorkspaceConnectionInfoResult', pipeline_response) @@ -502,64 +725,55 @@ def list_connection_info( return cls(pipeline_response, deserialized, {}) return deserialized + list_connection_info.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo'} # type: ignore + def _regenerate_auth_token_initial( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._regenerate_auth_token_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_regenerate_auth_token_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self._regenerate_auth_token_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _regenerate_auth_token_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken'} # type: ignore + + @distributed_trace def begin_regenerate_auth_token( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any + ) -> LROPoller[None]: """Regenerates the auth token for the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -570,15 +784,17 @@ def begin_regenerate_auth_token( :type notebook_workspace_name: str or ~azure.mgmt.cosmosdb.models.NotebookWorkspaceName :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -593,22 +809,14 @@ def begin_regenerate_auth_token( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -620,64 +828,54 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_regenerate_auth_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken'} # type: ignore def _start_initial( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + notebook_workspace_name=notebook_workspace_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start'} # type: ignore + + @distributed_trace def begin_start( self, - resource_group_name, # type: str - account_name, # type: str - notebook_workspace_name, # type: Union[str, "_models.NotebookWorkspaceName"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + **kwargs: Any + ) -> LROPoller[None]: """Starts the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -688,15 +886,17 @@ def begin_start( :type notebook_workspace_name: str or ~azure.mgmt.cosmosdb.models.NotebookWorkspaceName :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -711,22 +911,14 @@ def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'notebookWorkspaceName': self._serialize.url("notebook_workspace_name", notebook_workspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -738,4 +930,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_operations.py index 4bf061fe78261..8b553c75c24d1 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.DocumentDB/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available Cosmos DB Resource Provider operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +127,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_partition_key_range_id_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_partition_key_range_id_operations.py index bc4ae138ce9eb..71f8ce08e8f46 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_partition_key_range_id_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_partition_key_range_id_operations.py @@ -5,23 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + partition_key_range_id: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + "partitionKeyRangeId": _SERIALIZER.url("partition_key_range_id", partition_key_range_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PartitionKeyRangeIdOperations(object): """PartitionKeyRangeIdOperations operations. @@ -45,17 +91,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - database_rid, # type: str - collection_rid, # type: str - partition_key_range_id, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PartitionMetricListResult"] + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + partition_key_range_id: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.PartitionMetricListResult"]: """Retrieves the metrics determined by the given filter for the given partition key range id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -73,7 +119,8 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionMetricListResult or the result of cls(response) + :return: An iterator like instance of either PartitionMetricListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -82,40 +129,41 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - 'partitionKeyRangeId': self._serialize.url("partition_key_range_id", partition_key_range_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + partition_key_range_id=partition_key_range_id, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_rid=database_rid, + collection_rid=collection_rid, + partition_key_range_id=partition_key_range_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionMetricListResult', pipeline_response) + deserialized = self._deserialize("PartitionMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,6 +181,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_partition_key_range_id_region_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_partition_key_range_id_region_operations.py index c1f20d6e41c2d..742bb083fd207 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_partition_key_range_id_region_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_partition_key_range_id_region_operations.py @@ -5,23 +5,71 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + region: str, + database_rid: str, + collection_rid: str, + partition_key_range_id: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "region": _SERIALIZER.url("region", region, 'str'), + "databaseRid": _SERIALIZER.url("database_rid", database_rid, 'str'), + "collectionRid": _SERIALIZER.url("collection_rid", collection_rid, 'str'), + "partitionKeyRangeId": _SERIALIZER.url("partition_key_range_id", partition_key_range_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PartitionKeyRangeIdRegionOperations(object): """PartitionKeyRangeIdRegionOperations operations. @@ -45,18 +93,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - region, # type: str - database_rid, # type: str - collection_rid, # type: str - partition_key_range_id, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PartitionMetricListResult"] + resource_group_name: str, + account_name: str, + region: str, + database_rid: str, + collection_rid: str, + partition_key_range_id: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.PartitionMetricListResult"]: """Retrieves the metrics determined by the given filter for the given partition key range id and region. @@ -77,7 +125,8 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartitionMetricListResult or the result of cls(response) + :return: An iterator like instance of either PartitionMetricListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -86,41 +135,43 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'region': self._serialize.url("region", region, 'str'), - 'databaseRid': self._serialize.url("database_rid", database_rid, 'str'), - 'collectionRid': self._serialize.url("collection_rid", collection_rid, 'str'), - 'partitionKeyRangeId': self._serialize.url("partition_key_range_id", partition_key_range_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + partition_key_range_id=partition_key_range_id, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + region=region, + database_rid=database_rid, + collection_rid=collection_rid, + partition_key_range_id=partition_key_range_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PartitionMetricListResult', pipeline_response) + deserialized = self._deserialize("PartitionMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,6 +189,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_operations.py index 6215b57d4ff6d..e1520cf81eba3 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_operations.py @@ -5,23 +5,63 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PercentileOperations(object): """PercentileOperations operations. @@ -45,14 +85,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PercentileMetricListResult"] + resource_group_name: str, + account_name: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.PercentileMetricListResult"]: """Retrieves the metrics determined by the given filter for the given database account. This url is only for PBS and Replication Latency data. @@ -65,7 +105,8 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PercentileMetricListResult or the result of cls(response) + :return: An iterator like instance of either PercentileMetricListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -74,37 +115,35 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PercentileMetricListResult', pipeline_response) + deserialized = self._deserialize("PercentileMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,6 +161,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_source_target_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_source_target_operations.py index 2405f0b9dcc79..698718c9206ec 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_source_target_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_source_target_operations.py @@ -5,23 +5,67 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + source_region: str, + target_region: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "sourceRegion": _SERIALIZER.url("source_region", source_region, 'str'), + "targetRegion": _SERIALIZER.url("target_region", target_region, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PercentileSourceTargetOperations(object): """PercentileSourceTargetOperations operations. @@ -45,16 +89,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - source_region, # type: str - target_region, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PercentileMetricListResult"] + resource_group_name: str, + account_name: str, + source_region: str, + target_region: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.PercentileMetricListResult"]: """Retrieves the metrics determined by the given filter for the given account, source and target region. This url is only for PBS and Replication Latency data. @@ -73,7 +117,8 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PercentileMetricListResult or the result of cls(response) + :return: An iterator like instance of either PercentileMetricListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -82,39 +127,39 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'sourceRegion': self._serialize.url("source_region", source_region, 'str'), - 'targetRegion': self._serialize.url("target_region", target_region, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + source_region=source_region, + target_region=target_region, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + source_region=source_region, + target_region=target_region, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PercentileMetricListResult', pipeline_response) + deserialized = self._deserialize("PercentileMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,6 +177,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_target_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_target_operations.py index d76ec885a2db0..55ef1cf728fa4 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_target_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_percentile_target_operations.py @@ -5,23 +5,65 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_metrics_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + target_region: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "targetRegion": _SERIALIZER.url("target_region", target_region, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PercentileTargetOperations(object): """PercentileTargetOperations operations. @@ -45,15 +87,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_metrics( self, - resource_group_name, # type: str - account_name, # type: str - target_region, # type: str - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PercentileMetricListResult"] + resource_group_name: str, + account_name: str, + target_region: str, + filter: str, + **kwargs: Any + ) -> Iterable["_models.PercentileMetricListResult"]: """Retrieves the metrics determined by the given filter for the given account target region. This url is only for PBS and Replication Latency data. @@ -69,7 +111,8 @@ def list_metrics( names), startTime, endTime, and timeGrain. The supported operator is eq. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PercentileMetricListResult or the result of cls(response) + :return: An iterator like instance of either PercentileMetricListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -78,38 +121,37 @@ def list_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'targetRegion': self._serialize.url("target_region", target_region, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + target_region=target_region, + filter=filter, + template_url=self.list_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + target_region=target_region, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PercentileMetricListResult', pipeline_response) + deserialized = self._deserialize("PercentileMetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,6 +169,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_private_endpoint_connections_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_private_endpoint_connections_operations.py index 7731f58e7ac91..be30dcf60baf1 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_private_endpoint_connections_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_private_endpoint_connections_operations.py @@ -5,25 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_database_account_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -47,13 +205,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database_account( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: """List all private endpoint connections on a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -61,8 +219,10 @@ def list_by_database_account( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -70,36 +230,33 @@ def list_by_database_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_by_database_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,19 +274,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_database_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Gets a private endpoint connection. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -148,28 +306,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,56 +331,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -242,17 +380,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -265,15 +405,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.cosmosdb.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -286,28 +430,21 @@ def begin_create_or_update( account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -319,64 +456,54 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -387,15 +514,17 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,22 +539,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -437,4 +558,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_private_link_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_private_link_resources_operations.py index 33fd3080fce71..257e3a46a4373 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_private_link_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_private_link_resources_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_database_account_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "groupName": _SERIALIZER.url("group_name", group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -45,13 +119,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_database_account( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateLinkResourceListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateLinkResourceListResult"]: """Gets the private link resources that need to be created for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,7 +133,8 @@ def list_by_database_account( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -68,36 +143,33 @@ def list_by_database_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_database_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_by_database_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_database_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,19 +187,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_database_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResource" + resource_group_name: str, + account_name: str, + group_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResource": """Gets the private link resources that need to be created for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -146,28 +219,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + group_name=group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -181,4 +244,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}'} # type: ignore + diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_database_accounts_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_database_accounts_operations.py index af1db7fc59a31..7e49c2e0f0987 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_database_accounts_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_database_accounts_operations.py @@ -5,23 +5,124 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_location_request( + subscription_id: str, + location: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_location_request( + subscription_id: str, + location: str, + instance_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableDatabaseAccountsOperations(object): """RestorableDatabaseAccountsOperations operations. @@ -45,12 +146,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_location( self, - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableDatabaseAccountsListResult"] + location: str, + **kwargs: Any + ) -> Iterable["_models.RestorableDatabaseAccountsListResult"]: """Lists all the restorable Azure Cosmos DB database accounts available under the subscription and in a region. This call requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. @@ -58,8 +159,10 @@ def list_by_location( :param location: Cosmos DB region, with spaces between words and each word capitalized. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDatabaseAccountsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] + :return: An iterator like instance of either RestorableDatabaseAccountsListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDatabaseAccountsListResult"] @@ -67,35 +170,31 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableDatabaseAccountsListResult', pipeline_response) + deserialized = self._deserialize("RestorableDatabaseAccountsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,22 +212,25 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableDatabaseAccountsListResult"] + **kwargs: Any + ) -> Iterable["_models.RestorableDatabaseAccountsListResult"]: """Lists all the restorable Azure Cosmos DB database accounts available under the subscription. This call requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDatabaseAccountsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] + :return: An iterator like instance of either RestorableDatabaseAccountsListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDatabaseAccountsListResult"] @@ -136,34 +238,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableDatabaseAccountsListResult', pipeline_response) + deserialized = self._deserialize("RestorableDatabaseAccountsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,18 +278,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts'} # type: ignore + @distributed_trace def get_by_location( self, - location, # type: str - instance_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RestorableDatabaseAccountGetResult" + 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. @@ -210,27 +308,17 @@ def get_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=self.get_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -244,4 +332,6 @@ def get_by_location( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}'} # type: ignore + diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_collections_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_collections_operations.py index 5fb6d81270a87..f8f6b0dce0d57 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_collections_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_collections_operations.py @@ -5,23 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location: str, + instance_id: str, + *, + restorable_mongodb_database_rid: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if restorable_mongodb_database_rid is not None: + query_parameters['restorableMongodbDatabaseRid'] = _SERIALIZER.query("restorable_mongodb_database_rid", restorable_mongodb_database_rid, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableMongodbCollectionsOperations(object): """RestorableMongodbCollectionsOperations operations. @@ -45,14 +86,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - location, # type: str - instance_id, # type: str - restorable_mongodb_database_rid=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableMongodbCollectionsListResult"] + location: str, + instance_id: str, + restorable_mongodb_database_rid: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RestorableMongodbCollectionsListResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB MongoDB collections under a specific database. This helps in scenario where container was accidentally deleted. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. @@ -64,8 +105,10 @@ def list( :param restorable_mongodb_database_rid: The resource ID of the MongoDB database. :type restorable_mongodb_database_rid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableMongodbCollectionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionsListResult] + :return: An iterator like instance of either RestorableMongodbCollectionsListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableMongodbCollectionsListResult"] @@ -73,38 +116,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if restorable_mongodb_database_rid is not None: - query_parameters['restorableMongodbDatabaseRid'] = self._serialize.query("restorable_mongodb_database_rid", restorable_mongodb_database_rid, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restorable_mongodb_database_rid=restorable_mongodb_database_rid, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restorable_mongodb_database_rid=restorable_mongodb_database_rid, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableMongodbCollectionsListResult', pipeline_response) + deserialized = self._deserialize("RestorableMongodbCollectionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,6 +162,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_databases_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_databases_operations.py index a9504b5b5186b..2b9c37b1e4e9c 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_databases_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_databases_operations.py @@ -5,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location: str, + instance_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableMongodbDatabasesOperations(object): """RestorableMongodbDatabasesOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - location, # type: str - instance_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableMongodbDatabasesListResult"] + location: str, + instance_id: str, + **kwargs: Any + ) -> Iterable["_models.RestorableMongodbDatabasesListResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB MongoDB databases under the restorable account. This helps in scenario where database was accidentally deleted to get the deletion time. This API requires @@ -62,8 +99,10 @@ def list( :param instance_id: The instanceId GUID of a restorable database account. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableMongodbDatabasesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasesListResult] + :return: An iterator like instance of either RestorableMongodbDatabasesListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableMongodbDatabasesListResult"] @@ -71,36 +110,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableMongodbDatabasesListResult', pipeline_response) + deserialized = self._deserialize("RestorableMongodbDatabasesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,6 +154,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_resources_operations.py index 13660359931b2..740065779ff2f 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_mongodb_resources_operations.py @@ -5,23 +5,67 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location: str, + instance_id: str, + *, + restore_location: Optional[str] = None, + restore_timestamp_in_utc: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if restore_location is not None: + query_parameters['restoreLocation'] = _SERIALIZER.query("restore_location", restore_location, 'str') + if restore_timestamp_in_utc is not None: + query_parameters['restoreTimestampInUtc'] = _SERIALIZER.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableMongodbResourcesOperations(object): """RestorableMongodbResourcesOperations operations. @@ -45,15 +89,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - location, # type: str - instance_id, # type: str - restore_location=None, # type: Optional[str] - restore_timestamp_in_utc=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableMongodbResourcesListResult"] + location: str, + instance_id: str, + restore_location: Optional[str] = None, + restore_timestamp_in_utc: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RestorableMongodbResourcesListResult"]: """Return a list of database and collection combo that exist on the account at the given timestamp and location. This helps in scenarios to validate what resources exist at given timestamp and location. This API requires @@ -68,8 +112,10 @@ def list( :param restore_timestamp_in_utc: The timestamp when the restorable resources existed. :type restore_timestamp_in_utc: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableMongodbResourcesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesListResult] + :return: An iterator like instance of either RestorableMongodbResourcesListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableMongodbResourcesListResult"] @@ -77,40 +123,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if restore_location is not None: - query_parameters['restoreLocation'] = self._serialize.query("restore_location", restore_location, 'str') - if restore_timestamp_in_utc is not None: - query_parameters['restoreTimestampInUtc'] = self._serialize.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restore_location=restore_location, + restore_timestamp_in_utc=restore_timestamp_in_utc, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restore_location=restore_location, + restore_timestamp_in_utc=restore_timestamp_in_utc, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableMongodbResourcesListResult', pipeline_response) + deserialized = self._deserialize("RestorableMongodbResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,6 +171,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_containers_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_containers_operations.py index 1a8fa9ac2af67..633ab198635f5 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_containers_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_containers_operations.py @@ -5,23 +5,70 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location: str, + instance_id: str, + *, + restorable_sql_database_rid: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if restorable_sql_database_rid is not None: + query_parameters['restorableSqlDatabaseRid'] = _SERIALIZER.query("restorable_sql_database_rid", restorable_sql_database_rid, 'str') + if start_time is not None: + query_parameters['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + if end_time is not None: + query_parameters['endTime'] = _SERIALIZER.query("end_time", end_time, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableSqlContainersOperations(object): """RestorableSqlContainersOperations operations. @@ -45,16 +92,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - location, # type: str - instance_id, # type: str - restorable_sql_database_rid=None, # type: Optional[str] - start_time=None, # type: Optional[str] - end_time=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableSqlContainersListResult"] + location: str, + instance_id: str, + restorable_sql_database_rid: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RestorableSqlContainersListResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB SQL containers under a specific database. This helps in scenario where container was accidentally deleted. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. @@ -70,8 +117,10 @@ def list( :param end_time: The snapshot create timestamp before which snapshots need to be listed. :type end_time: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableSqlContainersListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlContainersListResult] + :return: An iterator like instance of either RestorableSqlContainersListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlContainersListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableSqlContainersListResult"] @@ -79,42 +128,39 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if restorable_sql_database_rid is not None: - query_parameters['restorableSqlDatabaseRid'] = self._serialize.query("restorable_sql_database_rid", restorable_sql_database_rid, 'str') - if start_time is not None: - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - if end_time is not None: - query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restorable_sql_database_rid=restorable_sql_database_rid, + start_time=start_time, + end_time=end_time, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restorable_sql_database_rid=restorable_sql_database_rid, + start_time=start_time, + end_time=end_time, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableSqlContainersListResult', pipeline_response) + deserialized = self._deserialize("RestorableSqlContainersListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,6 +178,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_databases_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_databases_operations.py index 37a2dd18d2e5c..e2fa40a713896 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_databases_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_databases_operations.py @@ -5,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location: str, + instance_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableSqlDatabasesOperations(object): """RestorableSqlDatabasesOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - location, # type: str - instance_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableSqlDatabasesListResult"] + location: str, + instance_id: str, + **kwargs: Any + ) -> Iterable["_models.RestorableSqlDatabasesListResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB SQL databases under the restorable account. This helps in scenario where database was accidentally deleted to get the deletion time. This API requires @@ -62,8 +99,10 @@ def list( :param instance_id: The instanceId GUID of a restorable database account. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableSqlDatabasesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlDatabasesListResult] + :return: An iterator like instance of either RestorableSqlDatabasesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlDatabasesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableSqlDatabasesListResult"] @@ -71,36 +110,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableSqlDatabasesListResult', pipeline_response) + deserialized = self._deserialize("RestorableSqlDatabasesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,6 +154,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_resources_operations.py index ed78d7481ceed..42dbc1e91d8d2 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_sql_resources_operations.py @@ -5,23 +5,67 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location: str, + instance_id: str, + *, + restore_location: Optional[str] = None, + restore_timestamp_in_utc: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if restore_location is not None: + query_parameters['restoreLocation'] = _SERIALIZER.query("restore_location", restore_location, 'str') + if restore_timestamp_in_utc is not None: + query_parameters['restoreTimestampInUtc'] = _SERIALIZER.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RestorableSqlResourcesOperations(object): """RestorableSqlResourcesOperations operations. @@ -45,15 +89,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - location, # type: str - instance_id, # type: str - restore_location=None, # type: Optional[str] - restore_timestamp_in_utc=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RestorableSqlResourcesListResult"] + location: str, + instance_id: str, + restore_location: Optional[str] = None, + restore_timestamp_in_utc: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RestorableSqlResourcesListResult"]: """Return a list of database and container combo that exist on the account at the given timestamp and location. This helps in scenarios to validate what resources exist at given timestamp and location. This API requires @@ -68,8 +112,10 @@ def list( :param restore_timestamp_in_utc: The timestamp when the restorable resources existed. :type restore_timestamp_in_utc: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableSqlResourcesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesListResult] + :return: An iterator like instance of either RestorableSqlResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableSqlResourcesListResult"] @@ -77,40 +123,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if restore_location is not None: - query_parameters['restoreLocation'] = self._serialize.query("restore_location", restore_location, 'str') - if restore_timestamp_in_utc is not None: - query_parameters['restoreTimestampInUtc'] = self._serialize.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restore_location=restore_location, + restore_timestamp_in_utc=restore_timestamp_in_utc, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + instance_id=instance_id, + restore_location=restore_location, + restore_timestamp_in_utc=restore_timestamp_in_utc, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RestorableSqlResourcesListResult', pipeline_response) + deserialized = self._deserialize("RestorableSqlResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,6 +171,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_sql_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_sql_resources_operations.py index fda077e0ccdfb..ac20bb3db7167 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_sql_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_sql_resources_operations.py @@ -5,25 +5,1509 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_sql_databases_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_sql_database_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_sql_database_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_sql_database_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_sql_database_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_sql_database_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_sql_database_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_sql_database_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_sql_containers_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_sql_container_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_sql_container_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_sql_container_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_sql_container_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_sql_container_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_sql_container_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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/migrateToAutoscale') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_sql_container_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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/migrateToManualThroughput') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_sql_stored_procedures_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_sql_stored_procedure_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_sql_stored_procedure_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + 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}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_sql_stored_procedure_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_sql_user_defined_functions_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_sql_user_defined_function_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_sql_user_defined_function_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + 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}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_sql_user_defined_function_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_sql_triggers_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_sql_trigger_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + 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}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_sql_trigger_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + 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}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_sql_trigger_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_sql_role_definition_request( + role_definition_id: str, + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}') + path_format_arguments = { + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_sql_role_definition_request_initial( + role_definition_id: str, + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}') + path_format_arguments = { + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_sql_role_definition_request_initial( + role_definition_id: str, + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}') + path_format_arguments = { + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_sql_role_definitions_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_sql_role_assignment_request( + role_assignment_id: str, + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_sql_role_assignment_request_initial( + role_assignment_id: str, + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_sql_role_assignment_request_initial( + role_assignment_id: str, + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_sql_role_assignments_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_retrieve_continuous_backup_information_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "containerName": _SERIALIZER.url("container_name", container_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class SqlResourcesOperations(object): """SqlResourcesOperations operations. @@ -47,13 +1531,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_sql_databases( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlDatabaseListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlDatabaseListResult"]: """Lists the SQL databases under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -61,7 +1545,8 @@ def list_sql_databases( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlDatabaseListResult or the result of cls(response) + :return: An iterator like instance of either SqlDatabaseListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlDatabaseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,36 +1555,33 @@ def list_sql_databases( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_databases.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_sql_databases.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_databases_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SqlDatabaseListResult', pipeline_response) + deserialized = self._deserialize("SqlDatabaseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,19 +1599,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_sql_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases'} # type: ignore + @distributed_trace def get_sql_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlDatabaseGetResults" + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> "_models.SqlDatabaseGetResults": """Gets the SQL database under an existing Azure Cosmos DB database account with the provided name. @@ -149,28 +1632,18 @@ def get_sql_database( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_database.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_database_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_sql_database.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -184,49 +1657,40 @@ def get_sql_database( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore + def _create_update_sql_database_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - create_update_sql_database_parameters, # type: "_models.SqlDatabaseCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SqlDatabaseGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + create_update_sql_database_parameters: "_models.SqlDatabaseCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SqlDatabaseGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlDatabaseGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_sql_database_parameters, 'SqlDatabaseCreateUpdateParameters') + + request = build_create_update_sql_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_database_parameters, 'SqlDatabaseCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,17 +1706,19 @@ def _create_update_sql_database_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore + + @distributed_trace def begin_create_update_sql_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - create_update_sql_database_parameters, # type: "_models.SqlDatabaseCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlDatabaseGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + create_update_sql_database_parameters: "_models.SqlDatabaseCreateUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.SqlDatabaseGetResults"]: """Create or update an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -263,18 +1729,23 @@ def begin_create_update_sql_database( :type database_name: str :param create_update_sql_database_parameters: The parameters to provide for the current SQL database. - :type create_update_sql_database_parameters: ~azure.mgmt.cosmosdb.models.SqlDatabaseCreateUpdateParameters + :type create_update_sql_database_parameters: + ~azure.mgmt.cosmosdb.models.SqlDatabaseCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlDatabaseGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SqlDatabaseGetResults or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlDatabaseGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -287,28 +1758,21 @@ def begin_create_update_sql_database( account_name=account_name, database_name=database_name, create_update_sql_database_parameters=create_update_sql_database_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlDatabaseGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -320,41 +1784,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore def _delete_sql_database_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_database_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_database_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._delete_sql_database_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -367,14 +1823,15 @@ def _delete_sql_database_initial( _delete_sql_database_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore + + @distributed_trace def begin_delete_sql_database( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -385,15 +1842,17 @@ def begin_delete_sql_database( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -408,22 +1867,14 @@ def begin_delete_sql_database( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -435,16 +1886,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}'} # type: ignore + @distributed_trace def get_sql_database_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -464,28 +1916,18 @@ def get_sql_database_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_database_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_database_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.get_sql_database_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -499,49 +1941,40 @@ def get_sql_database_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default'} # type: ignore + def _update_sql_database_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_sql_database_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_sql_database_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + content_type=content_type, + json=_json, + template_url=self._update_sql_database_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -557,17 +1990,19 @@ def _update_sql_database_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_sql_database_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_sql_database_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> 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. @@ -578,18 +2013,23 @@ def begin_update_sql_database_throughput( :type database_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the current SQL database. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -602,28 +2042,21 @@ def begin_update_sql_database_throughput( account_name=account_name, database_name=database_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -635,43 +2068,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_sql_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default'} # type: ignore def _migrate_sql_database_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_sql_database_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_sql_database_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_sql_database_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -687,16 +2110,18 @@ def _migrate_sql_database_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_sql_database_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_sql_database_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -707,15 +2132,18 @@ def begin_migrate_sql_database_to_autoscale( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -730,25 +2158,17 @@ def begin_migrate_sql_database_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -760,43 +2180,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_sql_database_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_sql_database_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_sql_database_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_sql_database_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self._migrate_sql_database_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -812,16 +2222,18 @@ def _migrate_sql_database_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_sql_database_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_sql_database_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -832,15 +2244,18 @@ def begin_migrate_sql_database_to_manual_throughput( :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -855,25 +2270,17 @@ def begin_migrate_sql_database_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -885,16 +2292,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_sql_database_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_sql_containers( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlContainerListResult"] + resource_group_name: str, + account_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlContainerListResult"]: """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. @@ -904,7 +2312,8 @@ def list_sql_containers( :param database_name: Cosmos DB database name. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlContainerListResult or the result of cls(response) + :return: An iterator like instance of either SqlContainerListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -913,37 +2322,35 @@ def list_sql_containers( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_containers.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_containers_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=self.list_sql_containers.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_containers_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SqlContainerListResult', pipeline_response) + deserialized = self._deserialize("SqlContainerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -961,20 +2368,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_sql_containers.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers'} # type: ignore + @distributed_trace def get_sql_container( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlContainerGetResults" + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> "_models.SqlContainerGetResults": """Gets 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. @@ -995,29 +2403,19 @@ def get_sql_container( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_container.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_container_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.get_sql_container.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1031,51 +2429,42 @@ def get_sql_container( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_container.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore + def _create_update_sql_container_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - create_update_sql_container_parameters, # type: "_models.SqlContainerCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SqlContainerGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + create_update_sql_container_parameters: "_models.SqlContainerCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SqlContainerGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlContainerGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_container_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_sql_container_parameters, 'SqlContainerCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_sql_container_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_container_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_container_parameters, 'SqlContainerCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1091,18 +2480,20 @@ def _create_update_sql_container_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_container_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore + + @distributed_trace def begin_create_update_sql_container( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - create_update_sql_container_parameters, # type: "_models.SqlContainerCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlContainerGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + create_update_sql_container_parameters: "_models.SqlContainerCreateUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.SqlContainerGetResults"]: """Create or update an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1115,18 +2506,23 @@ def begin_create_update_sql_container( :type container_name: str :param create_update_sql_container_parameters: The parameters to provide for the current SQL container. - :type create_update_sql_container_parameters: ~azure.mgmt.cosmosdb.models.SqlContainerCreateUpdateParameters + :type create_update_sql_container_parameters: + ~azure.mgmt.cosmosdb.models.SqlContainerCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlContainerGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SqlContainerGetResults or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlContainerGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1140,29 +2536,21 @@ def begin_create_update_sql_container( database_name=database_name, container_name=container_name, create_update_sql_container_parameters=create_update_sql_container_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlContainerGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1174,43 +2562,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_container.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore def _delete_sql_container_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_container_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_container_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self._delete_sql_container_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1223,15 +2603,16 @@ def _delete_sql_container_initial( _delete_sql_container_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore + + @distributed_trace def begin_delete_sql_container( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1244,15 +2625,17 @@ def begin_delete_sql_container( :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1268,23 +2651,14 @@ def begin_delete_sql_container( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1296,17 +2670,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_container.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}'} # type: ignore + @distributed_trace def get_sql_container_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -1328,29 +2703,19 @@ def get_sql_container_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_container_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_container_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.get_sql_container_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1364,51 +2729,42 @@ def get_sql_container_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_container_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default'} # type: ignore + def _update_sql_container_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_sql_container_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_sql_container_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + content_type=content_type, + json=_json, + template_url=self._update_sql_container_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1424,18 +2780,20 @@ def _update_sql_container_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_sql_container_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_sql_container_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **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. @@ -1448,18 +2806,23 @@ def begin_update_sql_container_throughput( :type container_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the current SQL container. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1473,29 +2836,21 @@ def begin_update_sql_container_throughput( database_name=database_name, container_name=container_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1507,45 +2862,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_sql_container_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default'} # type: ignore def _migrate_sql_container_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_sql_container_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_sql_container_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self._migrate_sql_container_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1561,17 +2906,19 @@ def _migrate_sql_container_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_sql_container_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_sql_container_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -1584,15 +2931,18 @@ def begin_migrate_sql_container_to_autoscale( :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1608,26 +2958,17 @@ def begin_migrate_sql_container_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1639,45 +2980,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_sql_container_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_sql_container_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_sql_container_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_sql_container_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self._migrate_sql_container_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1693,17 +3024,19 @@ def _migrate_sql_container_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_sql_container_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_sql_container_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -1716,15 +3049,18 @@ def begin_migrate_sql_container_to_manual_throughput( :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -1740,26 +3076,17 @@ def begin_migrate_sql_container_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1771,17 +3098,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_sql_container_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + @distributed_trace def list_sql_stored_procedures( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlStoredProcedureListResult"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlStoredProcedureListResult"]: """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. @@ -1793,7 +3121,8 @@ def list_sql_stored_procedures( :param container_name: Cosmos DB container name. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlStoredProcedureListResult or the result of cls(response) + :return: An iterator like instance of either SqlStoredProcedureListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -1802,38 +3131,37 @@ def list_sql_stored_procedures( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_stored_procedures.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_stored_procedures_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.list_sql_stored_procedures.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_stored_procedures_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SqlStoredProcedureListResult', pipeline_response) + deserialized = self._deserialize("SqlStoredProcedureListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1851,21 +3179,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_sql_stored_procedures.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures'} # type: ignore + @distributed_trace def get_sql_stored_procedure( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - stored_procedure_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlStoredProcedureGetResults" + 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. @@ -1888,30 +3217,20 @@ def get_sql_stored_procedure( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_stored_procedure.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_stored_procedure_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + stored_procedure_name=stored_procedure_name, + template_url=self.get_sql_stored_procedure.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1925,53 +3244,44 @@ def get_sql_stored_procedure( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore + def _create_update_sql_stored_procedure_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - stored_procedure_name, # type: str - create_update_sql_stored_procedure_parameters, # type: "_models.SqlStoredProcedureCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SqlStoredProcedureGetResults"] + 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", + **kwargs: Any + ) -> Optional["_models.SqlStoredProcedureGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlStoredProcedureGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_stored_procedure_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_sql_stored_procedure_parameters, 'SqlStoredProcedureCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_sql_stored_procedure_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + stored_procedure_name=stored_procedure_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_stored_procedure_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_stored_procedure_parameters, 'SqlStoredProcedureCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1987,19 +3297,21 @@ def _create_update_sql_stored_procedure_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_stored_procedure_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore + + @distributed_trace def begin_create_update_sql_stored_procedure( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - stored_procedure_name, # type: str - create_update_sql_stored_procedure_parameters, # type: "_models.SqlStoredProcedureCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlStoredProcedureGetResults"] + 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", + **kwargs: Any + ) -> 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. @@ -2014,18 +3326,23 @@ def begin_create_update_sql_stored_procedure( :type stored_procedure_name: str :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current SQL storedProcedure. - :type create_update_sql_stored_procedure_parameters: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters + :type create_update_sql_stored_procedure_parameters: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlStoredProcedureGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlStoredProcedureGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -2040,30 +3357,21 @@ def begin_create_update_sql_stored_procedure( container_name=container_name, stored_procedure_name=stored_procedure_name, create_update_sql_stored_procedure_parameters=create_update_sql_stored_procedure_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlStoredProcedureGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2075,45 +3383,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore def _delete_sql_stored_procedure_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - stored_procedure_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_stored_procedure_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_stored_procedure_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + stored_procedure_name=stored_procedure_name, + template_url=self._delete_sql_stored_procedure_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2126,16 +3426,17 @@ def _delete_sql_stored_procedure_initial( _delete_sql_stored_procedure_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore + + @distributed_trace def begin_delete_sql_stored_procedure( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - stored_procedure_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + 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. @@ -2150,15 +3451,17 @@ def begin_delete_sql_stored_procedure( :type stored_procedure_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2175,24 +3478,14 @@ def begin_delete_sql_stored_procedure( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2204,17 +3497,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} # type: ignore + @distributed_trace def list_sql_user_defined_functions( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlUserDefinedFunctionListResult"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlUserDefinedFunctionListResult"]: """Lists the SQL userDefinedFunction under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -2226,8 +3520,10 @@ def list_sql_user_defined_functions( :param container_name: Cosmos DB container name. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlUserDefinedFunctionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionListResult] + :return: An iterator like instance of either SqlUserDefinedFunctionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlUserDefinedFunctionListResult"] @@ -2235,38 +3531,37 @@ def list_sql_user_defined_functions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_user_defined_functions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_user_defined_functions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.list_sql_user_defined_functions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_user_defined_functions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SqlUserDefinedFunctionListResult', pipeline_response) + deserialized = self._deserialize("SqlUserDefinedFunctionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2284,21 +3579,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_sql_user_defined_functions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions'} # type: ignore + @distributed_trace def get_sql_user_defined_function( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - user_defined_function_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlUserDefinedFunctionGetResults" + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + **kwargs: Any + ) -> "_models.SqlUserDefinedFunctionGetResults": """Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -2321,30 +3617,20 @@ def get_sql_user_defined_function( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_user_defined_function.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_user_defined_function_request( + subscription_id=self._config.subscription_id, + 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, + template_url=self.get_sql_user_defined_function.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2358,53 +3644,44 @@ def get_sql_user_defined_function( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_user_defined_function.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore + def _create_update_sql_user_defined_function_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - user_defined_function_name, # type: str - create_update_sql_user_defined_function_parameters, # type: "_models.SqlUserDefinedFunctionCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SqlUserDefinedFunctionGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + create_update_sql_user_defined_function_parameters: "_models.SqlUserDefinedFunctionCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SqlUserDefinedFunctionGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlUserDefinedFunctionGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_user_defined_function_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_sql_user_defined_function_parameters, 'SqlUserDefinedFunctionCreateUpdateParameters') + + request = build_create_update_sql_user_defined_function_request_initial( + subscription_id=self._config.subscription_id, + 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, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_user_defined_function_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_user_defined_function_parameters, 'SqlUserDefinedFunctionCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2420,19 +3697,21 @@ def _create_update_sql_user_defined_function_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_user_defined_function_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore + + @distributed_trace def begin_create_update_sql_user_defined_function( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - user_defined_function_name, # type: str - create_update_sql_user_defined_function_parameters, # type: "_models.SqlUserDefinedFunctionCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlUserDefinedFunctionGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + create_update_sql_user_defined_function_parameters: "_models.SqlUserDefinedFunctionCreateUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.SqlUserDefinedFunctionGetResults"]: """Create or update an Azure Cosmos DB SQL userDefinedFunction. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -2447,18 +3726,24 @@ def begin_create_update_sql_user_defined_function( :type user_defined_function_name: str :param create_update_sql_user_defined_function_parameters: The parameters to provide for the current SQL userDefinedFunction. - :type create_update_sql_user_defined_function_parameters: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionCreateUpdateParameters + :type create_update_sql_user_defined_function_parameters: + ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlUserDefinedFunctionGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SqlUserDefinedFunctionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlUserDefinedFunctionGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -2473,30 +3758,21 @@ def begin_create_update_sql_user_defined_function( container_name=container_name, user_defined_function_name=user_defined_function_name, create_update_sql_user_defined_function_parameters=create_update_sql_user_defined_function_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlUserDefinedFunctionGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2508,45 +3784,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_user_defined_function.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore def _delete_sql_user_defined_function_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - user_defined_function_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_user_defined_function_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_user_defined_function_request_initial( + subscription_id=self._config.subscription_id, + 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, + template_url=self._delete_sql_user_defined_function_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2559,16 +3827,17 @@ def _delete_sql_user_defined_function_initial( _delete_sql_user_defined_function_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore + + @distributed_trace def begin_delete_sql_user_defined_function( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - user_defined_function_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + 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. @@ -2583,15 +3852,17 @@ def begin_delete_sql_user_defined_function( :type user_defined_function_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2608,24 +3879,14 @@ def begin_delete_sql_user_defined_function( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'userDefinedFunctionName': self._serialize.url("user_defined_function_name", user_defined_function_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2637,17 +3898,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_user_defined_function.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}'} # type: ignore + @distributed_trace def list_sql_triggers( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlTriggerListResult"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlTriggerListResult"]: """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. @@ -2659,7 +3921,8 @@ def list_sql_triggers( :param container_name: Cosmos DB container name. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlTriggerListResult or the result of cls(response) + :return: An iterator like instance of either SqlTriggerListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -2668,38 +3931,37 @@ def list_sql_triggers( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_triggers.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_triggers_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=self.list_sql_triggers.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_triggers_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SqlTriggerListResult', pipeline_response) + deserialized = self._deserialize("SqlTriggerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2717,21 +3979,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_sql_triggers.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers'} # type: ignore + @distributed_trace def get_sql_trigger( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - trigger_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlTriggerGetResults" + 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. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -2754,30 +4017,20 @@ def get_sql_trigger( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_trigger.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_trigger_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + trigger_name=trigger_name, + template_url=self.get_sql_trigger.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2791,53 +4044,44 @@ def get_sql_trigger( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore + def _create_update_sql_trigger_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - trigger_name, # type: str - create_update_sql_trigger_parameters, # type: "_models.SqlTriggerCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SqlTriggerGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + create_update_sql_trigger_parameters: "_models.SqlTriggerCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SqlTriggerGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlTriggerGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_trigger_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_sql_trigger_parameters, 'SqlTriggerCreateUpdateParameters') + + request = build_create_update_sql_trigger_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + trigger_name=trigger_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_trigger_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_trigger_parameters, 'SqlTriggerCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2853,19 +4097,21 @@ def _create_update_sql_trigger_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_trigger_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore + + @distributed_trace def begin_create_update_sql_trigger( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - trigger_name, # type: str - create_update_sql_trigger_parameters, # type: "_models.SqlTriggerCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlTriggerGetResults"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + create_update_sql_trigger_parameters: "_models.SqlTriggerCreateUpdateParameters", + **kwargs: Any + ) -> 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. @@ -2880,18 +4126,23 @@ def begin_create_update_sql_trigger( :type trigger_name: str :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL trigger. - :type create_update_sql_trigger_parameters: ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters + :type create_update_sql_trigger_parameters: + ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlTriggerGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlTriggerGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -2906,30 +4157,21 @@ def begin_create_update_sql_trigger( container_name=container_name, trigger_name=trigger_name, create_update_sql_trigger_parameters=create_update_sql_trigger_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlTriggerGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2941,45 +4183,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore def _delete_sql_trigger_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - trigger_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_sql_trigger_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_sql_trigger_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + trigger_name=trigger_name, + template_url=self._delete_sql_trigger_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2992,16 +4226,17 @@ def _delete_sql_trigger_initial( _delete_sql_trigger_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore + + @distributed_trace def begin_delete_sql_trigger( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - trigger_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + 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. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -3016,15 +4251,17 @@ def begin_delete_sql_trigger( :type trigger_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3041,24 +4278,14 @@ def begin_delete_sql_trigger( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'triggerName': self._serialize.url("trigger_name", trigger_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3070,16 +4297,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}'} # type: ignore + @distributed_trace def get_sql_role_definition( self, - role_definition_id, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlRoleDefinitionGetResults" + 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. @@ -3098,28 +4326,18 @@ def get_sql_role_definition( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_role_definition.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_role_definition_request( + role_definition_id=role_definition_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get_sql_role_definition.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3133,49 +4351,40 @@ def get_sql_role_definition( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_role_definition.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore + def _create_update_sql_role_definition_initial( self, - role_definition_id, # type: str - resource_group_name, # type: str - account_name, # type: str - create_update_sql_role_definition_parameters, # type: "_models.SqlRoleDefinitionCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SqlRoleDefinitionGetResults"] + role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_definition_parameters: "_models.SqlRoleDefinitionCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SqlRoleDefinitionGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlRoleDefinitionGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_role_definition_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_sql_role_definition_parameters, 'SqlRoleDefinitionCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_sql_role_definition_request_initial( + role_definition_id=role_definition_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_role_definition_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_role_definition_parameters, 'SqlRoleDefinitionCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3191,17 +4400,19 @@ def _create_update_sql_role_definition_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_role_definition_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore + + @distributed_trace def begin_create_update_sql_role_definition( self, - role_definition_id, # type: str - resource_group_name, # type: str - account_name, # type: str - create_update_sql_role_definition_parameters, # type: "_models.SqlRoleDefinitionCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlRoleDefinitionGetResults"] + role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_definition_parameters: "_models.SqlRoleDefinitionCreateUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.SqlRoleDefinitionGetResults"]: """Creates or updates an Azure Cosmos DB SQL Role Definition. :param role_definition_id: The GUID for the Role Definition. @@ -3212,18 +4423,23 @@ def begin_create_update_sql_role_definition( :type account_name: str :param create_update_sql_role_definition_parameters: The properties required to create or update a Role Definition. - :type create_update_sql_role_definition_parameters: ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters + :type create_update_sql_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlRoleDefinitionGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlRoleDefinitionGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -3236,28 +4452,21 @@ def begin_create_update_sql_role_definition( resource_group_name=resource_group_name, account_name=account_name, create_update_sql_role_definition_parameters=create_update_sql_role_definition_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlRoleDefinitionGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3269,43 +4478,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_role_definition.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore def _delete_sql_role_definition_initial( self, - role_definition_id, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + role_definition_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_sql_role_definition_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_sql_role_definition_request_initial( + role_definition_id=role_definition_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self._delete_sql_role_definition_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3318,14 +4517,15 @@ def _delete_sql_role_definition_initial( _delete_sql_role_definition_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore + + @distributed_trace def begin_delete_sql_role_definition( self, - role_definition_id, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + role_definition_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB SQL Role Definition. :param role_definition_id: The GUID for the Role Definition. @@ -3336,15 +4536,17 @@ def begin_delete_sql_role_definition( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3359,22 +4561,14 @@ def begin_delete_sql_role_definition( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3386,15 +4580,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_role_definition.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}'} # type: ignore + @distributed_trace def list_sql_role_definitions( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlRoleDefinitionListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlRoleDefinitionListResult"]: """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. @@ -3402,7 +4597,8 @@ def list_sql_role_definitions( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlRoleDefinitionListResult or the result of cls(response) + :return: An iterator like instance of either SqlRoleDefinitionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -3411,36 +4607,33 @@ def list_sql_role_definitions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_role_definitions.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_role_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_sql_role_definitions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_role_definitions_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SqlRoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3458,19 +4651,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_sql_role_definitions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions'} # type: ignore + @distributed_trace def get_sql_role_assignment( self, - role_assignment_id, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlRoleAssignmentGetResults" + role_assignment_id: str, + resource_group_name: str, + account_name: 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. @@ -3489,28 +4683,18 @@ def get_sql_role_assignment( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_sql_role_assignment.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_sql_role_assignment_request( + role_assignment_id=role_assignment_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get_sql_role_assignment.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3524,49 +4708,40 @@ def get_sql_role_assignment( return cls(pipeline_response, deserialized, {}) return deserialized + get_sql_role_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore + def _create_update_sql_role_assignment_initial( self, - role_assignment_id, # type: str - resource_group_name, # type: str - account_name, # type: str - create_update_sql_role_assignment_parameters, # type: "_models.SqlRoleAssignmentCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SqlRoleAssignmentGetResults"] + role_assignment_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_assignment_parameters: "_models.SqlRoleAssignmentCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SqlRoleAssignmentGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlRoleAssignmentGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_sql_role_assignment_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_update_sql_role_assignment_parameters, 'SqlRoleAssignmentCreateUpdateParameters') + + request = build_create_update_sql_role_assignment_request_initial( + role_assignment_id=role_assignment_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self._create_update_sql_role_assignment_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_sql_role_assignment_parameters, 'SqlRoleAssignmentCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3582,17 +4757,19 @@ def _create_update_sql_role_assignment_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_sql_role_assignment_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore + + @distributed_trace def begin_create_update_sql_role_assignment( self, - role_assignment_id, # type: str - resource_group_name, # type: str - account_name, # type: str - create_update_sql_role_assignment_parameters, # type: "_models.SqlRoleAssignmentCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlRoleAssignmentGetResults"] + role_assignment_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_assignment_parameters: "_models.SqlRoleAssignmentCreateUpdateParameters", + **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. @@ -3603,18 +4780,23 @@ def begin_create_update_sql_role_assignment( :type account_name: str :param create_update_sql_role_assignment_parameters: The properties required to create or update a Role Assignment. - :type create_update_sql_role_assignment_parameters: ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentCreateUpdateParameters + :type create_update_sql_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlRoleAssignmentGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SqlRoleAssignmentGetResults or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlRoleAssignmentGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -3627,28 +4809,21 @@ def begin_create_update_sql_role_assignment( resource_group_name=resource_group_name, account_name=account_name, create_update_sql_role_assignment_parameters=create_update_sql_role_assignment_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SqlRoleAssignmentGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3660,43 +4835,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_sql_role_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore def _delete_sql_role_assignment_initial( self, - role_assignment_id, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + role_assignment_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._delete_sql_role_assignment_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_sql_role_assignment_request_initial( + role_assignment_id=role_assignment_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self._delete_sql_role_assignment_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3709,14 +4874,15 @@ def _delete_sql_role_assignment_initial( _delete_sql_role_assignment_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore + + @distributed_trace def begin_delete_sql_role_assignment( self, - role_assignment_id, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + role_assignment_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB SQL Role Assignment. :param role_assignment_id: The GUID for the Role Assignment. @@ -3727,15 +4893,17 @@ def begin_delete_sql_role_assignment( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3750,22 +4918,14 @@ def begin_delete_sql_role_assignment( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3777,15 +4937,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_sql_role_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}'} # type: ignore + @distributed_trace def list_sql_role_assignments( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlRoleAssignmentListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlRoleAssignmentListResult"]: """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. @@ -3793,7 +4954,8 @@ def list_sql_role_assignments( :param account_name: Cosmos DB database account name. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlRoleAssignmentListResult or the result of cls(response) + :return: An iterator like instance of either SqlRoleAssignmentListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -3802,36 +4964,33 @@ def list_sql_role_assignments( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_sql_role_assignments.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_role_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_sql_role_assignments.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_sql_role_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SqlRoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3849,6 +5008,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -3856,47 +5016,36 @@ def get_next(next_link=None): def _retrieve_continuous_backup_information_initial( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - location, # type: "_models.ContinuousBackupRestoreLocation" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BackupInformation"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + location: "_models.ContinuousBackupRestoreLocation", + **kwargs: Any + ) -> Optional["_models.BackupInformation"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BackupInformation"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._retrieve_continuous_backup_information_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + + request = build_retrieve_continuous_backup_information_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + content_type=content_type, + json=_json, + template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(location, 'ContinuousBackupRestoreLocation') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3912,18 +5061,20 @@ def _retrieve_continuous_backup_information_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _retrieve_continuous_backup_information_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation'} # type: ignore + + @distributed_trace def begin_retrieve_continuous_backup_information( self, - resource_group_name, # type: str - account_name, # type: str - database_name, # type: str - container_name, # type: str - location, # type: "_models.ContinuousBackupRestoreLocation" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BackupInformation"] + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + location: "_models.ContinuousBackupRestoreLocation", + **kwargs: Any + ) -> 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. @@ -3938,15 +5089,19 @@ def begin_retrieve_continuous_backup_information( :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BackupInformation or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInformation"] lro_delay = kwargs.pop( 'polling_interval', @@ -3960,29 +5115,21 @@ def begin_retrieve_continuous_backup_information( database_name=database_name, container_name=container_name, location=location, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BackupInformation', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3994,4 +5141,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_retrieve_continuous_backup_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation'} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_table_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_table_resources_operations.py index 22cf3ea1b70e5..7ebb275c9ae12 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_table_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_table_resources_operations.py @@ -5,25 +5,334 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_tables_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_table_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_update_table_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + table_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_table_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_table_throughput_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_table_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + table_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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]+)*'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_table_to_autoscale_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_migrate_table_to_manual_throughput_request_initial( + subscription_id: str, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/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', min_length=1), + "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]+)*'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class TableResourcesOperations(object): """TableResourcesOperations operations. @@ -47,13 +356,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_tables( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TableListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.TableListResult"]: """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. @@ -70,36 +379,33 @@ def list_tables( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_tables.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_tables_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_tables.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_tables_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TableListResult', pipeline_response) + deserialized = self._deserialize("TableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,19 +423,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_tables.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables'} # type: ignore + @distributed_trace def get_table( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TableGetResults" + 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. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -148,28 +455,18 @@ def get_table( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_table.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_table_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self.get_table.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,49 +480,40 @@ def get_table( return cls(pipeline_response, deserialized, {}) return deserialized + get_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore + def _create_update_table_initial( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - create_update_table_parameters, # type: "_models.TableCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.TableGetResults"] + resource_group_name: str, + account_name: str, + table_name: str, + create_update_table_parameters: "_models.TableCreateUpdateParameters", + **kwargs: Any + ) -> Optional["_models.TableGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.TableGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_update_table_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_update_table_parameters, 'TableCreateUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_update_table_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + content_type=content_type, + json=_json, + template_url=self._create_update_table_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_update_table_parameters, 'TableCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -241,17 +529,19 @@ def _create_update_table_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_update_table_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore + + @distributed_trace def begin_create_update_table( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - create_update_table_parameters, # type: "_models.TableCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.TableGetResults"] + resource_group_name: str, + account_name: str, + table_name: str, + create_update_table_parameters: "_models.TableCreateUpdateParameters", + **kwargs: Any + ) -> 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. @@ -264,15 +554,19 @@ def begin_create_update_table( :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either TableGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.TableGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -285,28 +579,21 @@ def begin_create_update_table( account_name=account_name, table_name=table_name, create_update_table_parameters=create_update_table_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('TableGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -318,41 +605,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_update_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore def _delete_table_initial( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - - # Construct URL - url = self._delete_table_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_table_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self._delete_table_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -365,14 +644,15 @@ def _delete_table_initial( _delete_table_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore + + @distributed_trace def begin_delete_table( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -383,15 +663,17 @@ def begin_delete_table( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -406,22 +688,14 @@ def begin_delete_table( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -433,16 +707,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}'} # type: ignore + @distributed_trace def get_table_throughput( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ThroughputSettingsGetResults" + 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. @@ -462,28 +737,18 @@ def get_table_throughput( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self.get_table_throughput.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_table_throughput_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self.get_table_throughput.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -497,49 +762,40 @@ def get_table_throughput( return cls(pipeline_response, deserialized, {}) return deserialized + get_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default'} # type: ignore + def _update_table_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + table_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_table_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + + request = build_update_table_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + content_type=content_type, + json=_json, + template_url=self._update_table_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -555,17 +811,19 @@ def _update_table_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_table_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default'} # type: ignore + + @distributed_trace def begin_update_table_throughput( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - update_throughput_parameters, # type: "_models.ThroughputSettingsUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + table_name: str, + update_throughput_parameters: "_models.ThroughputSettingsUpdateParameters", + **kwargs: Any + ) -> 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. @@ -576,18 +834,23 @@ def begin_update_table_throughput( :type table_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the current Table. - :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -600,28 +863,21 @@ def begin_update_table_throughput( account_name=account_name, table_name=table_name, update_throughput_parameters=update_throughput_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -633,43 +889,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default'} # type: ignore def _migrate_table_to_autoscale_initial( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_table_to_autoscale_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_table_to_autoscale_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self._migrate_table_to_autoscale_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -685,16 +931,18 @@ def _migrate_table_to_autoscale_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_table_to_autoscale_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale'} # type: ignore + + @distributed_trace def begin_migrate_table_to_autoscale( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -705,15 +953,18 @@ def begin_migrate_table_to_autoscale( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -728,25 +979,17 @@ def begin_migrate_table_to_autoscale( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -758,43 +1001,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_table_to_autoscale.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale'} # type: ignore def _migrate_table_to_manual_throughput_initial( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ThroughputSettingsGetResults"] + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any + ) -> Optional["_models.ThroughputSettingsGetResults"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ThroughputSettingsGetResults"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-15" - accept = "application/json" - - # Construct URL - url = self._migrate_table_to_manual_throughput_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_migrate_table_to_manual_throughput_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + template_url=self._migrate_table_to_manual_throughput_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -810,16 +1043,18 @@ def _migrate_table_to_manual_throughput_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _migrate_table_to_manual_throughput_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore + + @distributed_trace def begin_migrate_table_to_manual_throughput( self, - resource_group_name, # type: str - account_name, # type: str - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ThroughputSettingsGetResults"] + 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. @@ -830,15 +1065,18 @@ def begin_migrate_table_to_manual_throughput( :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ThroughputSettingsGetResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -853,25 +1091,17 @@ def begin_migrate_table_to_manual_throughput( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), - 'tableName': self._serialize.url("table_name", table_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -883,4 +1113,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_migrate_table_to_manual_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput'} # type: ignore